Accessible360/accessible-carousel-boilerplates

Splide: resume autoplay not firing

5ulo opened this issue · 1 comments

5ulo commented

Pause is working, resuming to play not working.

https://accessible360.github.io/accessible-carousel-boilerplates/Splide/hero-banner.html

The problem is in the function toggleAutoplay() where you look for splide option autoplay, which always returns true. You have to overide this option in if statement. See example bellow.

function toggleAutoplay() {
    var autoplayEnabled = splide.options.autoplay;

    if (autoplayEnabled) {
        disableAutoplay();
        splide.options = { autoplay: false }; // <-- this is missing
    } else {
        enableAutoplay();
        splide.options = { autoplay: true }; // <-- this is missing
    }
}

Hey @5ulo! Thanks so much for spotting this and suggesting the fix. I've updated the Splide hero banner example with this, and it works great! I've also gone ahead and pushed the same change to the mirror over on CodePen too.