jQuery mobile swipe spamming and animation

Posted by halliewuud on Stack Overflow See other posts from Stack Overflow or by halliewuud
Published on 2012-03-21T17:14:17Z Indexed on 2012/03/21 17:30 UTC
Read the original article Hit count: 196

Filed under:
|
|

I have say 5 list items with images inside placed 200px from eachother. I am trying to animate these list items to slide horizontally left if one presses a link with the id = #next or if one swipes left. And vice versa for sliding the list items right.

Every click or swipe results in a slide animation of 200px on every list item. I ran into a problem where spamming the #next or #prev button would cancel the current animation and start a new one. This results in list items not sliding 200px+200px+200... but something like this 200px+140px+120... This because like I said the animation is cut and therefore the sliding distance will be shorter.

Now I solved this for the clicking event by disabling the button before the animation starts and then re'enabling it on the end callbak function. But this problem is remaining for the swipe event.

How can I solve this problem for the swipe event?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery