Touchsweep
Detect your swipe events direction
Installation
npm install touchsweep
# or
yarn add touchsweep
Usage
import TouchSweep from 'touchsweep';
const area = document.getElementById('area');
const instance = new TouchSweep(
area,
{
value: 1
},
20
);
area.addEventListener('swipeleft', event => {
// Swipe direction: left
});
area.addEventListener('swiperight', event => {
// Swipe direction: right
});
area.addEventListener('swipeup', event => {
// Swipe direction: up
});
area.addEventListener('swipedown', event => {
// Swipe direction: down
});
area.addEventListener('swipemove', event => {
// Swipe direction: none
// Swipe event: swipemove
});
area.addEventListener('tap', event => {
// Swipe direction: none
});