Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeverEnding not behaving #10

Open
sjoerdlo opened this issue May 4, 2015 · 3 comments
Open

NeverEnding not behaving #10

sjoerdlo opened this issue May 4, 2015 · 3 comments
Labels

Comments

@sjoerdlo
Copy link

sjoerdlo commented May 4, 2015

Hi Dirk,

I've just implemented your jQuery slider, nice work.

One problem with the neverEnding setting. I've implemented a previous arrow and a next arrow and I have 3 slides. Every time you click the next arrow and wait till the sliding transition has ended before you click another time on the next arrow, it goes to the next slides perfectly and loops "never ending".

However, if you click the next arrow, and during the slide transition you click another time, then at the final slide the slides slide back (sliding left instead of right) to the first slide as if the neverEnding setting was set to false. It doesn't loop anymore.

My code:

$('#slider').simpleSlider({
        slides: '.slide',
        slideOnInterval: false,
        magneticSwipe: false,
        slideTracker: false,
        //neverEnding: false
    });
    slider = $('#slider').data("simpleslider");
    $('.control_next').click( function() {
        slider.nextSlide(); // Go to the next slide
    });
    $('.control_prev').click( function() {
        slider.prevSlide(); // Go to the previous slide
    });
@dirkgroenen
Copy link
Owner

This indeed is a bug at the moment. The sliding mechanism clones the first and last slide and adds it to the end and beginning of the slide container. When you call the next slide it will go to all slides + 1 (which visualizes the first), but when you call the next slide again it will go to slide 2.

I will look into this as soon as possible, but at the moment the only workaround would be to prevent sliding when the slider is sliding.

In case of your implementation that would like something like this:

var sliding = false;

$("#slider").on("beforeSliding", function(event){
    sliding = true;
});

$("#slider").on("afterSliding", function(event){
    sliding = false;
});

$('.control_prev').click( function() {
    if(!sliding){
        slider.prevSlide(); // Go to the previous slide
    }
});

@sjoerdlo
Copy link
Author

sjoerdlo commented May 4, 2015

Thanks for the quick reply and the workaround.

One other quirky thing is when you have only 2 slides and neverEnding: true. Clicking the next button makes the slider go left instead of right.

@dirkgroenen dirkgroenen added the bug label May 4, 2015
@dirkgroenen
Copy link
Owner

Funky, I will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants