MOBILE-4081 swipe-slides: Book chapter tags not always shown

main
Alfonso Salces 2022-11-25 15:44:45 +01:00
parent 034d0b4e0c
commit ff7d7eb12f
1 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,7 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
protected resizeListener: CoreEventObserver;
protected updateSlidesPromise?: Promise<void>;
protected activeSlideIndexes: number[] = [];
protected mutationObserver: MutationObserver;
constructor(
elementRef: ElementRef<HTMLElement>,
@ -53,9 +54,17 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
) {
this.hostElement = elementRef.nativeElement;
this.resizeListener = CoreDom.onWindowResize(() => {
this.updateSlidesComponent();
this.resizeListener = CoreDom.onWindowResize(async () => {
await this.updateSlidesComponent();
});
this.mutationObserver = new MutationObserver(() => {
setTimeout(async () => {
await this.updateSlidesComponent();
}, 100);
});
this.mutationObserver.observe(this.hostElement, { subtree: true, childList: true });
}
/**
@ -312,6 +321,7 @@ export class CoreSwipeSlidesComponent<Item = unknown> implements OnChanges, OnDe
ngOnDestroy(): void {
this.unsubscribe && this.unsubscribe();
this.resizeListener.off();
this.mutationObserver.disconnect();
}
}