admin管理员组

文章数量:1323715

I have a scrollable list in my web app, using scrollability to deal with the overflow:scroll feature. although when I finish scrolling and take my finger out of the screen the event bellow also triggers.

$('li').live('touchend', function (e) {
    //...
});

The thing is that I only would like this event above to fire when the action there's no touchmove event before that.

it is possible to suppress a touchend event from inside the touchmove event? so it simulates better the iOS UITableView ponent? where when touchmove starts it cancels the target for touchend

I have a scrollable list in my web app, using scrollability to deal with the overflow:scroll feature. although when I finish scrolling and take my finger out of the screen the event bellow also triggers.

$('li').live('touchend', function (e) {
    //...
});

The thing is that I only would like this event above to fire when the action there's no touchmove event before that.

it is possible to suppress a touchend event from inside the touchmove event? so it simulates better the iOS UITableView ponent? where when touchmove starts it cancels the target for touchend

Share Improve this question asked Mar 10, 2012 at 18:05 zanonazanona 12.7k25 gold badges90 silver badges146 bronze badges 2
  • Perhaps set a flag in touchmove which can be tested in touchend and if the flag is set, just skip the functionality and possibly preventDefault() (either way, reset the flag at the end). – Yaniro Commented Mar 10, 2012 at 18:59
  • thanks a lot Yaniro, that was the smartest thing to do in this case. If you could set this as an anser I would be happy to mark this a correct :) – zanona Commented Mar 11, 2012 at 10:33
Add a ment  | 

1 Answer 1

Reset to default 8

Set a flag in touchmove which can be tested in touchend and if the flag is set, just skip the functionality and possibly preventDefault() (either way, reset the flag at the end).

本文标签: javascriptcanceling touchend event when touchmove startsStack Overflow