[SOLVED] Detect swipe on mobile

Hi,

Has anyone a simple solution to detect a swipe? I’m making a scroll view that snaps when the user releases it, but i also want the user to do quick swipes to the next screen. however, i don’t know how to do that without interfering with the scroll view swipe behaviour… any ideas?

Thanks in advance!

Would the scroll direction and the swipe gesture be in the same axis (eg both horizontal) on opposite?)

Yes, it is a horizontal scroll view, with 3 choices. the snap behaviour needs to make sure it always lands on one of the options (to show that you choose that option). and the swipes would also be horizontal, to change your choice

I would default to the scroll behaviour but keep track of when and where the touch started. When the touch ends, look at the time and distance travelled to work out a velocity and if it’s high enough, do a swipe gesture.

You may need to play around with numbers and perhaps some logic to get it ‘right’ but that’s the general idea.