forked from EVOgeek/Vmeda.Online
		
	Merge pull request #3261 from dpalou/MOBILE-3833
MOBILE-3833 course: Remove unneeded scroll handling
This commit is contained in:
		
						commit
						97997d11fa
					
				| @ -147,6 +147,10 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit, A | |||||||
|      * Recovers last set scroll position. |      * Recovers last set scroll position. | ||||||
|      */ |      */ | ||||||
|     protected async recoverScrollPosition(): Promise<void> { |     protected async recoverScrollPosition(): Promise<void> { | ||||||
|  |         if (this.scroll <= 0) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         const content = this.element.closest('ion-content'); |         const content = this.element.closest('ion-content'); | ||||||
|         if (!content) { |         if (!content) { | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ | |||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, ViewChild, OnInit, OnDestroy, forwardRef } from '@angular/core'; | import { Component, ViewChild, OnInit, OnDestroy, forwardRef, ChangeDetectorRef } from '@angular/core'; | ||||||
| import { IonContent, IonRefresher } from '@ionic/angular'; | import { IonContent, IonRefresher } from '@ionic/angular'; | ||||||
| 
 | 
 | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -73,6 +73,8 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon | |||||||
|     protected modulesHaveCompletion = false; |     protected modulesHaveCompletion = false; | ||||||
|     protected debouncedUpdateCachedCompletion?: () => void; // Update the cached completion after a certain time.
 |     protected debouncedUpdateCachedCompletion?: () => void; // Update the cached completion after a certain time.
 | ||||||
| 
 | 
 | ||||||
|  |     constructor(protected changeDetectorRef: ChangeDetectorRef) {} | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
| @ -352,12 +354,8 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon | |||||||
|      */ |      */ | ||||||
|     protected async showLoadingAndRefresh(sync = false, invalidateData = true): Promise<void> { |     protected async showLoadingAndRefresh(sync = false, invalidateData = true): Promise<void> { | ||||||
|         // Save scroll position to restore it once done.
 |         // Save scroll position to restore it once done.
 | ||||||
|         const scrollElement = await this.content?.getScrollElement(); |  | ||||||
|         const scrollTop = scrollElement?.scrollTop || 0; |  | ||||||
|         const scrollLeft = scrollElement?.scrollLeft || 0; |  | ||||||
| 
 |  | ||||||
|         this.updatingData = true; |         this.updatingData = true; | ||||||
|         this.content?.scrollToTop(0); // Scroll top so the spinner is seen.
 |         this.changeDetectorRef.detectChanges(); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             if (invalidateData) { |             if (invalidateData) { | ||||||
| @ -369,11 +367,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.updatingData = false; |             this.updatingData = false; | ||||||
| 
 |             this.changeDetectorRef.detectChanges(); | ||||||
|             // Wait for new content height to be calculated and scroll without animation.
 |  | ||||||
|             setTimeout(() => { |  | ||||||
|                 this.content?.scrollToPoint(scrollLeft, scrollTop, 0); |  | ||||||
|             }); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user