Javascript Module to handle swipe events on DOM elements - that emits events on swipe.
npm install swipeitswipeit is a simple touch event manager for detecting Swipe on a DOM Element. Once registered it emits events when it's swiped; I decided to use cardinal events because it seems more direct than left, right. So events are east, west, north and south.
swipeit is a Javascript Module, when it's compiled with Browserify it works out of the box - if module is not found then it will bind itself to window under the variable swipeit. ie: window.swipeit;
npm install Swipeit --save
var swipeit = require("swipeit");var element = document.querySelector("div.swipable");
var swipeit = new Swipeit(element);
swipeit.on("east", function(){
.....
})
`API
$3
Creates a new swipper for the DOM Element passed as argument. You can create many swipper instances for different elements.$3
EVENT can be east, west, north and southThe callback is a function, it is passed a parameter with the following object:
`
{
amount: the swipe amount in pixels
event: the original swipe ( touchmove ) event
}
``Todo: Make it compatible with other require.js and ES6 Modules.