0
How to respond to ‘swipe’ touchmove events?
I want to use ‘swiping’ touch movements in an small online game (swipe up, swipe left, etc.) Does anyone know the best way to do this?? I googled touch events and found a sort-of-helpful page: https://www.w3schools.com/jsref/obj_touchevent.asp Also I found how to get coordinades of touchmove events on html elements: https://code.sololearn.com/WDkNGEFIot4o/?ref=app Thanks!
1 Resposta
+ 5
1. declare global variables startx starty without initializing
2. in touchstart listener, store the event client positions into the global variables startx starty
3. in touchend and touchcancel listener, store the event client positions into local variables endx and endy, calculate the differences and then follow happy to help's logic above.