K
K
KindOfHeaven2016-12-20 13:23:16
css
KindOfHeaven, 2016-12-20 13:23:16

How to block the slider at run time?

How can I block the slider at runtime?
Here is the code:

$('#left').click(function() {
    var carusel = $(this).parent('.slider')[0]
    var slide_width = 277
    $(carusel).find('.slider-track .slide').eq(0).clone().appendTo($(carusel).find('.slider-track'))
    $(carusel).find('.slider-track').animate({"margin-left": "-"+slide_width},650)
    setTimeout(function() {
      $(carusel).find('.slider-track .slide').eq(0).remove()
      $(carusel).find('.slider-track').css({'margin-left': 0})
    }, 700)
  })

The problem is that if you click on the arrow very quickly everything breaks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2016-12-20
@KindOfHeaven

var im_running = false;
$('#left').click(function() {
if(im_running == false){
im_running = true;
//some logic
im_running = false;
}
});

D
Denis Derepko, 2016-12-20
@uDenX

Add a variable where to store the state of the slider? If there is an animation, then we do nothing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question