diff --git a/packages/embla-carousel-auto-scroll/src/components/AutoScroll.ts b/packages/embla-carousel-auto-scroll/src/components/AutoScroll.ts index 7065dfdee..4a4b069bf 100644 --- a/packages/embla-carousel-auto-scroll/src/components/AutoScroll.ts +++ b/packages/embla-carousel-auto-scroll/src/components/AutoScroll.ts @@ -99,8 +99,6 @@ function AutoScroll(userOptions: AutoScrollOptionsType = {}): AutoScrollType { } function destroy(): void { - destroyed = true - playing = false emblaApi .off('init', startScroll) .off('reInit', startScroll) @@ -108,6 +106,8 @@ function AutoScroll(userOptions: AutoScrollOptionsType = {}): AutoScrollType { .off('pointerUp', startScrollOnSettle) .off('settle', onSettle) stopScroll() + destroyed = true + playing = false } function startScroll(): void { diff --git a/packages/embla-carousel-autoplay/src/components/Autoplay.ts b/packages/embla-carousel-autoplay/src/components/Autoplay.ts index 94c504f27..13d5e56f9 100644 --- a/packages/embla-carousel-autoplay/src/components/Autoplay.ts +++ b/packages/embla-carousel-autoplay/src/components/Autoplay.ts @@ -95,8 +95,6 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType { } function destroy(): void { - destroyed = true - playing = false emblaApi .off('init', startTimer) .off('reInit', startTimer) @@ -105,6 +103,8 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType { stopTimer() cancelAnimationFrame(animationFrame) animationFrame = 0 + destroyed = true + playing = false } function startTimer(): void {