MOBILE-4015 course: Fix keep scroll when refresh
parent
dc6ca1f085
commit
e85acc6868
|
@ -1,9 +1,9 @@
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<ion-refresher slot="fixed" [disabled]="!dataLoaded || !displayRefresher" (ionRefresh)="doRefresh($event.target)">
|
<ion-refresher slot="fixed" [disabled]="!dataLoaded || updatingData || !displayRefresher" (ionRefresh)="doRefresh($event.target)">
|
||||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
|
|
||||||
<core-loading [hideUntil]="dataLoaded">
|
<core-loading [hideUntil]="dataLoaded && !updatingData">
|
||||||
<core-course-format [course]="course" [sections]="sections" [initialSectionId]="sectionId" [initialSectionNumber]="sectionNumber"
|
<core-course-format [course]="course" [sections]="sections" [initialSectionId]="sectionId" [initialSectionNumber]="sectionNumber"
|
||||||
[moduleId]="moduleId" class="core-course-format-{{course.format}}" *ngIf="dataLoaded">
|
[moduleId]="moduleId" class="core-course-format-{{course.format}}" *ngIf="dataLoaded">
|
||||||
</core-course-format>
|
</core-course-format>
|
||||||
|
|
|
@ -59,6 +59,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
|
||||||
sectionId?: number;
|
sectionId?: number;
|
||||||
sectionNumber?: number;
|
sectionNumber?: number;
|
||||||
dataLoaded = false;
|
dataLoaded = false;
|
||||||
|
updatingData = false;
|
||||||
downloadCourseEnabled = false;
|
downloadCourseEnabled = false;
|
||||||
moduleId?: number;
|
moduleId?: number;
|
||||||
displayEnableDownload = false;
|
displayEnableDownload = false;
|
||||||
|
@ -355,7 +356,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
|
||||||
const scrollTop = scrollElement?.scrollTop || 0;
|
const scrollTop = scrollElement?.scrollTop || 0;
|
||||||
const scrollLeft = scrollElement?.scrollLeft || 0;
|
const scrollLeft = scrollElement?.scrollLeft || 0;
|
||||||
|
|
||||||
this.dataLoaded = false;
|
this.updatingData = true;
|
||||||
this.content?.scrollToTop(0); // Scroll top so the spinner is seen.
|
this.content?.scrollToTop(0); // Scroll top so the spinner is seen.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -367,7 +368,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
|
||||||
|
|
||||||
await this.formatComponent?.doRefresh(undefined, undefined, true);
|
await this.formatComponent?.doRefresh(undefined, undefined, true);
|
||||||
} finally {
|
} finally {
|
||||||
this.dataLoaded = true;
|
this.updatingData = false;
|
||||||
|
|
||||||
// Wait for new content height to be calculated and scroll without animation.
|
// Wait for new content height to be calculated and scroll without animation.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Loading…
Reference in New Issue