Skip to content

Commit

Permalink
Update carousel.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Dec 14, 2023
1 parent 927c10b commit a0bb313
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cigaradvisor/blocks/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ import { isExternal } from '../../scripts/scripts.js';

function setAutoScroll(moveSlides, slidesWrapper) {
let interval;
let interacting = false;
setTimeout(() => {
interval = setInterval(() => {
moveSlides('next');
}, 6000);

// Stop auto-scroll on user interaction
slidesWrapper.addEventListener('mouseenter', () => {
clearInterval(interval);
});
if (!interacting) {
interval = setInterval(() => {
moveSlides('next');
}, 6000);
}
slidesWrapper.addEventListener('mouseleave', () => {
interacting = false;
interval = setInterval(() => {
moveSlides('next');
}, 6000);
});
}, 3000);

// Stop auto-scroll on user interaction
slidesWrapper.addEventListener('mouseenter', () => {
interacting = true;
clearInterval(interval);
});
}

function createButtons(moveSlides) {
Expand Down

0 comments on commit a0bb313

Please sign in to comment.