From ff7d7eb12fc87f96457662da1e576dbe4afce5a6 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Fri, 25 Nov 2022 15:44:45 +0100 Subject: [PATCH] MOBILE-4081 swipe-slides: Book chapter tags not always shown --- src/core/components/swipe-slides/swipe-slides.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/components/swipe-slides/swipe-slides.ts b/src/core/components/swipe-slides/swipe-slides.ts index 561b55356..f7ab8106b 100644 --- a/src/core/components/swipe-slides/swipe-slides.ts +++ b/src/core/components/swipe-slides/swipe-slides.ts @@ -46,6 +46,7 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe protected resizeListener: CoreEventObserver; protected updateSlidesPromise?: Promise; protected activeSlideIndexes: number[] = []; + protected mutationObserver: MutationObserver; constructor( elementRef: ElementRef, @@ -53,9 +54,17 @@ export class CoreSwipeSlidesComponent 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 implements OnChanges, OnDe ngOnDestroy(): void { this.unsubscribe && this.unsubscribe(); this.resizeListener.off(); + this.mutationObserver.disconnect(); } }