jquery - How to allow only one JavaScript 'click' method to be clicked at a time while animation is executing? -


when element clicked, div slides off screen center. when element clicked, other div in center slides off screen , div slides in.

the issue occurs when element clicked before initial div has time slide center of screen.

$('#about').click(function(){    /* makes visible div slide out , slides in 'about' div */ });  $('#contact').click(function(){    /* makes visible div slide out , slides in 'contact' div */ }); 

in other words, when click about , right away click contact both slide in inconsistently.

i tried "attrremove", "unbind", "off"... , although work disable clicks, cannot enable them again.

one way approach through use of variable indicates if action in effect. if want queue event (so don't entirely disregard click (as example below doing), code modified add queue of sort.

var slideinprogress = false;  $('#about').click(function(){     if (!slideinprogress) {         slideinprogress = true;         $("#slider").slidetoggle(5000, function(){         slideinprogress = false;     });   } }); 

a simple, put fiddle example here: https://jsfiddle.net/t8tcr0rp/


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -