From 44cc2ca7c64541a0ac384229e68c145b9f42adb1 Mon Sep 17 00:00:00 2001 From: David Jerleke Date: Mon, 19 Feb 2024 11:49:06 +0100 Subject: [PATCH] Bug fix for #750. --- .../embla-carousel-auto-scroll/src/components/AutoScroll.ts | 4 ++-- packages/embla-carousel-autoplay/src/components/Autoplay.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 {