Skip to content

Commit 7c8d372

Browse files
authored
Merge pull request #3263 from dpalou/MOBILE-3833
Mobile 3833
2 parents e38992b + 21200ea commit 7c8d372

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/core/components/swipe-slides/swipe-slides.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
import { CoreSwipeSlidesItemsManager } from '@classes/items-management/swipe-slides-items-manager';
1919
import { IonContent, IonSlides } from '@ionic/angular';
2020
import { CoreDomUtils, VerticalPoint } from '@services/utils/dom';
21+
import { CoreDom } from '@singletons/dom';
22+
import { CoreEventObserver } from '@singletons/events';
2123
import { CoreMath } from '@singletons/math';
2224

2325
/**
@@ -40,12 +42,17 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
4042

4143
protected hostElement: HTMLElement;
4244
protected unsubscribe?: () => void;
45+
protected resizeListener: CoreEventObserver;
4346

4447
constructor(
4548
elementRef: ElementRef<HTMLElement>,
4649
protected content?: IonContent,
4750
) {
4851
this.hostElement = elementRef.nativeElement;
52+
53+
this.resizeListener = CoreDom.onWindowResize(() => {
54+
this.slides?.update();
55+
});
4956
}
5057

5158
/**
@@ -247,6 +254,7 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
247254
*/
248255
ngOnDestroy(): void {
249256
this.unsubscribe && this.unsubscribe();
257+
this.resizeListener.off();
250258
}
251259

252260
}

src/core/features/course/components/course-format/course-format.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,14 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
509509
const moduleIdToScroll = this.moduleId && previousValue === undefined ? this.moduleId : moduleId;
510510
if (moduleIdToScroll) {
511511
this.scrollToModule(moduleIdToScroll);
512-
} else {
513-
this.content.scrollToTop(0);
514512
}
515513

516-
if (!previousValue || previousValue.id != newSection.id) {
517-
// First load or section changed, add log in Moodle.
514+
if (!previousValue || previousValue.id !== newSection.id) {
515+
// First load or section changed.
516+
if (!moduleIdToScroll) {
517+
this.content.scrollToTop(0);
518+
}
519+
518520
CoreUtils.ignoreErrors(
519521
CoreCourse.logView(this.course.id, newSection.section, undefined, this.course.fullname),
520522
);

0 commit comments

Comments
 (0)