A lightweight JavaScript library for simple touch swipe gesture events.
npm i swipyjs
yarn add swipyjs
Define Swipy event listeners by calling on(event, callback)
:
let swipy = new Swipy(document.getElementById('swipy-container'));
swipy.on('swipeleft', function(event, touches) {
console.log('Swiped to the left!');
});
The callback function receives two parameters:
event
: the last nativetouchmove
event that was triggered.touches
: an object containing the current touch coordinates:
{
down: {x: null, y: null},
up: {x: null, y: null},
diff: {x: null, y: null}
}
Registers a new Swipy event listener.
Available events are:
swipetop
swiperight
swipebottom
swipeleft
Adds the native event listeners used by the library.
Removes the native event listeners used by the library.
Manually triggers a defined Swipy event.