I have a drag event handler which starts (1) an animation, and (2) adjust a counter. When I drag the target, multiple handlers will be triggered several times, and the counter is wrong. The touch event is based on Hammer.js.
$(hammer).on('swipeleft',function(){
doAnimation();
counter++;
}
Note that the handler could be triggered for multiple times both because multiple events in a continuous (long) drag, and user's quickly dragging for multiple times during the animation (so that I cannot rely on 'release' event?).
Also, the doAnimation() is wrapped in a separate animation library, so I don't want to mess some codes in that library (unless I have no other choices). An extreme case is that I use -webkit-transition feature to implement the animation,
$(hammer).on('swipeleft',function(){
$('.content').css('width',0);//-webkit-transition: all 0.5s ease;
counter++;
}
How can I deal with such situation?