rosin
A tiny single-finger tap and swipe library. Works with touch and/or mouse events. 700 bytes gzipped.
Install
npm i rosin --save
Usage
; const swiper = ;
Emitted values are relative to the DOM node you instantiated on.
swiper;swiper;swiper; /** Fired once on each swipe */swiper;swiper;swiper;swiper;
Drag events emit a different payload. It looks like this:
{
ix, // initial X coordinate
iy, // initial Y coordinate
dx, // delta (change) in X coordinate
dy, // delta (change) in Y coordinate
x, // current X coordinate
y, // current Y coordinate
}
/** Fired on every animation frame */swiper;swiper;swiper;swiper;swiper;
Each emitter also returns a function to destroy itself:
const tapListener = swiper; ; // destroy listener
To destroy the entire instance:
swiper;
License
MIT License © Eric Bailey