diff --git a/packages/embla-carousel-autoplay/src/components/Autoplay.ts b/packages/embla-carousel-autoplay/src/components/Autoplay.ts index 4538adf79..59fab4592 100644 --- a/packages/embla-carousel-autoplay/src/components/Autoplay.ts +++ b/packages/embla-carousel-autoplay/src/components/Autoplay.ts @@ -57,9 +57,6 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType { const emblaRoot = emblaApi.rootNode() const root = (options.rootNode && options.rootNode(emblaRoot)) || emblaRoot - emblaApi.on('pointerDown', clearTimer) - if (!options.stopOnInteraction) emblaApi.on('pointerUp', startTimer) - if (options.stopOnMouseEnter) { eventStore.add(root, 'mouseenter', clearTimer) @@ -68,6 +65,14 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType { } } + if (!options.stopOnMouseEnter) { + emblaApi.on('pointerDown', clearTimer) + + if (!options.stopOnInteraction) { + emblaApi.on('pointerUp', startTimer) + } + } + if (options.stopOnFocusIn) { eventStore.add(root, 'focusin', clearTimer)