[Help]: Custom Autoplay delay for each slide #1113
-
SummaryGood morning First of all - thank you so much for a great carousel library, it is simply amazing 👍🎉. I'm trying to implement a carousel, where each slide has a custom delay (each slide is an object with name, url for either image or video, and then a delay value in seconds). So, what i want to be able to somehow pass to Embla Autoplay is something like I've been searching for this for a while now, coming across #743 and trying to implement it, however no matter what I try, the carousel just goes into a very fast loop (as if the delay was 0). This is what I have now: let duration = 25;
let delays = [{ delay: 3 }, { delay: 6 }, { delay: 1 }, { delay: 10 }];
// let delay = 20000;
let options = { loop: true, duration };
let plugins = [
Autoplay({
delay: (scrollSnapList) => delays.map(({ delay }) => (delay || 5) * 1000),
stopOnInteraction: false,
stopOnFocusIn: false
})
]; I assume it must be due to my inexperience with JS/TS, however I can't pinpoint where exactly. It works all fine with delay set for a fixed number as expected. Could you please assist? Thank you If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationUsing Embla with Svelte + SvelteKit CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @rabus, Thank you for your question. Please make sure the Embla version you're using is |
Beta Was this translation helpful? Give feedback.
Hi @rabus,
Thank you for your question. Please make sure the Embla version you're using is
8.5.0
or higher because this feature was included in the 8.5.2 release. Which version are you using?