MOBILE-3320 quiz: Fix scroll after clicking Check button

main
Dani Palou 2021-06-15 08:40:02 +02:00
parent 007a7c857e
commit b2a051723b
1 changed files with 5 additions and 3 deletions

View File

@ -215,7 +215,6 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
// Reload the current page.
const scrollElement = await this.content?.getScrollElement();
const scrollTop = scrollElement?.scrollTop || -1;
const scrollLeft = scrollElement?.scrollLeft || -1;
this.loaded = false;
this.content?.scrollToTop(); // Scroll top so the spinner is seen.
@ -224,8 +223,11 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
await this.loadPage(this.attempt!.currentpage!);
} finally {
this.loaded = true;
if (scrollTop != -1 && scrollLeft != -1) {
this.content?.scrollToPoint(scrollLeft, scrollTop);
if (scrollTop != -1) {
// Wait for content to be rendered.
setTimeout(() => {
this.content?.scrollToPoint(0, scrollTop);
}, 50);
}
}
} catch (error) {