Swipe icon indicating copy to clipboard operation
Swipe copied to clipboard

Automatic advancing of slides stops when slide() method is called.

Open peterugh opened this issue 12 years ago • 3 comments

I have pagination working correctly for my slideshow with the ability to jump to a slide using the slide() method. However, after I manually go to a slide, the autoplay stops working.

I'm using jQuery 1.9.1 although the plugin itself does not require it. See example code below, which performs correctly, moving the slides manually using pagination, but stops autoplay after that is invoked.

P.S. I didn't see this exact issue raised anywhere else.

function buildSwipeNav(){
    var controlsContainer = $("#featured_nav");
    var totalSlides = window.mySwipe.getNumSlides();
    var menuMarkup = '<ul>';
    for(i = 0; i < totalSlides; i++){
        menuMarkup = menuMarkup + '<a href="#" data-slide-index="' + i + '">' + i + '</a>';
    }
    menuMarkup = menuMarkup + '</ul>';
    controlsContainer.html(menuMarkup);
    $('[data-slide-index=0]').addClass('active_slide');
}

function moveSlidesHome(evt){
    evt.preventDefault();
    var slideTarget = $(this).data('slide-index');clicked
    window.mySwipe.slide(slideTarget, 500);
}

function slidHome(index){
    $("#featured_nav a").removeClass('active_slide');
    $('[data-slide-index=' + index + ']').addClass('active_slide');
}

window.mySwipe = new Swipe(document.getElementById('slider'), {
    speed: 500,
    auto: 1000,
    transitionEnd: slidHome
});
buildSwipeNav();
$(document).on('click', '#featured_nav a', moveSlidesHome)

peterugh avatar Jun 25 '13 19:06 peterugh

I have the same issue. temp fix by adding mySwipe.start(); after mySwipe.slide(); however it is a little buggy, sometimes jumping 2 slides

alycda avatar Aug 12 '13 00:08 alycda

I've run into the "jump 2 slides" issues as well. I'm investigating further though I believe the double sliding is because begin() is being called twice, or being called when it doesn't need to be. Try adding an additional delay = options.auto || 0 in the slide method for now.

trose avatar Aug 12 '13 15:08 trose

Call restart() or start() method in transitionEnd hook can resolve "jump 2 slides" issues.

Arguseye avatar Mar 14 '17 03:03 Arguseye