Skip to content

Commit 230549d

Browse files
Fixed event listener for continous autoplay
1 parent 356b8f1 commit 230549d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/components/blogCarousel/blogCarousel.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ export function BlogCarousel() {
2727
setCount(api.scrollSnapList().length);
2828
setCurrent(api.selectedScrollSnap() + 1);
2929

30-
api.on("select", () => {
30+
const onSelect = () => {
3131
setCurrent(api.selectedScrollSnap() + 1);
32-
});
32+
};
33+
34+
api.on("select", onSelect);
35+
36+
return () => {
37+
api.off("select", onSelect);
38+
};
3339
}, [api]);
3440

3541
return (
@@ -62,8 +68,9 @@ export function BlogCarousel() {
6268
}}
6369
plugins={[
6470
Autoplay({
65-
delay: 4000,
66-
stopOnInteraction: true,
71+
delay: 5000,
72+
stopOnInteraction: false,
73+
stopOnMouseEnter: true,
6774
}),
6875
]}
6976
>

0 commit comments

Comments
 (0)