diff --git a/src/slider/tp-slider-slide.ts b/src/slider/tp-slider-slide.ts index 22ce814..ef78565 100644 --- a/src/slider/tp-slider-slide.ts +++ b/src/slider/tp-slider-slide.ts @@ -22,6 +22,17 @@ export class TPSliderSlideElement extends HTMLElement { */ protected handleHeightChange(): void { const slider: TPSliderElement | null = this.closest( 'tp-slider' ); - slider?.handleResize(); + if ( ! slider ) { + return; + } + + /** + * Yield to main thread to avoid observation errors. + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors + */ + setTimeout( (): void => { + slider.handleResize(); + }, 0 ); } } diff --git a/src/slider/tp-slider.ts b/src/slider/tp-slider.ts index 87f2b06..0461783 100644 --- a/src/slider/tp-slider.ts +++ b/src/slider/tp-slider.ts @@ -56,7 +56,7 @@ export class TPSliderElement extends HTMLElement { document.fonts.ready.then( () => this.handleResize() ); } - this.addEventListener( 'touchstart', this.handleTouchStart.bind( this ) ); + this.addEventListener( 'touchstart', this.handleTouchStart.bind( this ), { passive: true } ); this.addEventListener( 'touchend', this.handleTouchEnd.bind( this ) ); }