forked from EVOgeek/Vmeda.Online
MOBILE-4362 course: Keep scroll position after refresh
parent
4ea7b56bde
commit
2d1a018304
|
@ -357,6 +357,10 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
|
||||||
* @returns Promise resolved when done.
|
* @returns Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async showLoadingAndRefresh(sync = false, invalidateData = true): Promise<void> {
|
protected async showLoadingAndRefresh(sync = false, invalidateData = true): Promise<void> {
|
||||||
|
// Try to keep current scroll position.
|
||||||
|
const scrollElement = await CoreUtils.ignoreErrors(this.content?.getScrollElement());
|
||||||
|
const scrollTop = scrollElement?.scrollTop ?? -1;
|
||||||
|
|
||||||
this.updatingData = true;
|
this.updatingData = true;
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
|
|
||||||
|
@ -371,6 +375,11 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
|
||||||
} finally {
|
} finally {
|
||||||
this.updatingData = false;
|
this.updatingData = false;
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
|
|
||||||
|
if (scrollTop > 0) {
|
||||||
|
await CoreUtils.nextTick();
|
||||||
|
this.content?.scrollToPoint(0, scrollTop, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue