Detect Swipe Events In Vanilla JavaScript – Swipe-it

Category: Javascript | October 10, 2016
Author: tri613
Views Total: 3,397
Official Page: Go to website
Last Update: October 10, 2016
License: MIT

Preview:

Detect Swipe Events In Vanilla JavaScript – Swipe-it

Description:

Swipe-it is a small, dependency-free JavaScript library which allows to detect and bind swipe events: swipe, swipeLeft, swipeRight, swipeUp, swipeDown. Mouse drag is supported as well.

How to use it:

Create an html element on which you’d like to detect the swipe events.

<div class="box">
  Swipe-it
</div>

Create a new SwipeIt object.

var mySwipeIt = new SwipeIt('.box');

Attach swipe events to the ‘mySwipeIt’ and add your custom handlers.

mySwipeIt
.on('swipeLeft',function(e){
    //your handler here
    alert('mySwipeIt is on swipeLeft!');
})
.on('swipeRight',function(e){
    //your handler here
    alert('mySwipeIt is on swipeRight!');
});

You Might Be Interested In:


Leave a Reply