简体   繁体   中英

Scrolling and touch events on iOS5

I have a list of tweets that you can scroll with -webkit-overflow-scrolling:touch . Each time you tap on tweet, it logs its number in a section at the top of the screen. So far, so good.

The problem is: when I launch a scroll and I try then to stop the ongoing scroll, I don't want to consider that tap as a "real" tap. That tap should just stop the current scroll but it shouldn't log any info.

You can try it by yourself on the iPhone or the simulator with this simple example . Here's a quick screencast showing the bug.

I hope I'm being clear enough!

Thanks, Ben

Your best bet is to create a variable in touchStart, then check for it in touchEnd and also check the change in x/y positions. If they haven't moved (more than say, 5px), it is a "tap" and not a "scroll".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM