javascript - Getting rid of the double click effect -


here's fiddle. can see i've defined simple click event handler:

$('#traveller > a').click(function(e) {     e.preventdefault();      var $ul = $('#traveller ul');     if($(this).hasclass('handle-next')) {         if(math.abs($ul.position().top - parentpadding) < totalheight - itemheight) {             $ul.animate({top: '-=' + itemheight});         }     }     else {         if($ul.position().top - parentpadding < 0) {              $ul.animate({top: '+=' + itemheight});         }     } }); 

i've noticed when make few double clicks quickly, pressing a.handle-next/a.handle-prev, ul position changes unexpectedly.

howcome avoid behavior?

just check if $ul animated:

if($ul.is(':animated')) return; 

demo


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -