Detecting Touch Swipe Gestures

by kirupa | 25 March 2018

In our web applications, you and I probably haven't done a whole lot of special work to handle touch-based input. Because touch is often treated as a mouse gesture, a lot of things just work for free. With that said, this doesn't mean we can't do a little extra to make our web content a bit more touch optimized. In this tutorial, the little extra is around detecting the direction of a touch swipe that we can then react to. We are going to do all of this using pure 100% grass-fed JavaScript. No 3rd party libraries will be necessary!

This is a companion discussion topic for the original entry at

This is BRILLIANT! Thank you for breaking this down SO clearly. Just amazing, and just what I needed to add a simple swiper on a custom slideshow. Woot!

1 Like

Glad it worked out :slight_smile:

Uncaught SyntaxError: Malformed arrow function parameter list

Can you post your code? The example on the site still works for me.