From fc50f2663e0a1722c5fd2e62385200624167eebb Mon Sep 17 00:00:00 2001 From: kailasnadh790 <53608019+kailasnadh790@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:42:14 -0500 Subject: [PATCH] Update carousel.js --- cigaradvisor/blocks/carousel/carousel.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cigaradvisor/blocks/carousel/carousel.js b/cigaradvisor/blocks/carousel/carousel.js index 49c34cc5..2a143e2e 100644 --- a/cigaradvisor/blocks/carousel/carousel.js +++ b/cigaradvisor/blocks/carousel/carousel.js @@ -2,9 +2,8 @@ import { isExternal } from '../../scripts/scripts.js'; function setAutoScroll(moveSlides, block) { let interval; - let interacting = false; setTimeout(() => { - if (!interacting) { + if (interval === undefined) { interval = setInterval(() => { moveSlides('next'); }, 6000); @@ -13,12 +12,17 @@ function setAutoScroll(moveSlides, block) { // Stop auto-scroll on user interaction block.addEventListener('mouseenter', () => { - interacting = true; clearInterval(interval); + interval = undefined; }); block.addEventListener('mouseleave', () => { - interacting = false; + if (interval === undefined) { + interval = setInterval(() => { + moveSlides('next'); + }, 6000); + console.log('after checking', interval); + } }); }