commit
7c8d372ec2
|
@ -18,6 +18,8 @@ import {
|
||||||
import { CoreSwipeSlidesItemsManager } from '@classes/items-management/swipe-slides-items-manager';
|
import { CoreSwipeSlidesItemsManager } from '@classes/items-management/swipe-slides-items-manager';
|
||||||
import { IonContent, IonSlides } from '@ionic/angular';
|
import { IonContent, IonSlides } from '@ionic/angular';
|
||||||
import { CoreDomUtils, VerticalPoint } from '@services/utils/dom';
|
import { CoreDomUtils, VerticalPoint } from '@services/utils/dom';
|
||||||
|
import { CoreDom } from '@singletons/dom';
|
||||||
|
import { CoreEventObserver } from '@singletons/events';
|
||||||
import { CoreMath } from '@singletons/math';
|
import { CoreMath } from '@singletons/math';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,12 +42,17 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
|
||||||
|
|
||||||
protected hostElement: HTMLElement;
|
protected hostElement: HTMLElement;
|
||||||
protected unsubscribe?: () => void;
|
protected unsubscribe?: () => void;
|
||||||
|
protected resizeListener: CoreEventObserver;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
elementRef: ElementRef<HTMLElement>,
|
elementRef: ElementRef<HTMLElement>,
|
||||||
protected content?: IonContent,
|
protected content?: IonContent,
|
||||||
) {
|
) {
|
||||||
this.hostElement = elementRef.nativeElement;
|
this.hostElement = elementRef.nativeElement;
|
||||||
|
|
||||||
|
this.resizeListener = CoreDom.onWindowResize(() => {
|
||||||
|
this.slides?.update();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,6 +254,7 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.unsubscribe && this.unsubscribe();
|
this.unsubscribe && this.unsubscribe();
|
||||||
|
this.resizeListener.off();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,12 +509,14 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
const moduleIdToScroll = this.moduleId && previousValue === undefined ? this.moduleId : moduleId;
|
const moduleIdToScroll = this.moduleId && previousValue === undefined ? this.moduleId : moduleId;
|
||||||
if (moduleIdToScroll) {
|
if (moduleIdToScroll) {
|
||||||
this.scrollToModule(moduleIdToScroll);
|
this.scrollToModule(moduleIdToScroll);
|
||||||
} else {
|
|
||||||
this.content.scrollToTop(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!previousValue || previousValue.id != newSection.id) {
|
if (!previousValue || previousValue.id !== newSection.id) {
|
||||||
// First load or section changed, add log in Moodle.
|
// First load or section changed.
|
||||||
|
if (!moduleIdToScroll) {
|
||||||
|
this.content.scrollToTop(0);
|
||||||
|
}
|
||||||
|
|
||||||
CoreUtils.ignoreErrors(
|
CoreUtils.ignoreErrors(
|
||||||
CoreCourse.logView(this.course.id, newSection.section, undefined, this.course.fullname),
|
CoreCourse.logView(this.course.id, newSection.section, undefined, this.course.fullname),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue