swipe-gesture

Swipe gesture library
Note: This library focused to performance and simplicity. For complex usecase (like long-tap or pinch), please use other library
Features
- No limit: not only for DOM
- Handles types for your
- Clean code
- Simple & Easy
- Performant
- UMD compatible
Demos
Installation
We recommend install via npm because of it's cache and flat node modules tree
npm i @dalisoft/swipe-gesture
then you able to import to Node.js/Browser easily
const SwipeGesture = require("@dalisoft/swipe-gesture");
import SwipeGesture from "@dalisoft/swipe-gesture";
Parameters
- onPointerDown
function(e: Event) - Call like pointerdown
- onPointerMove
function(e: Event) - Call like pointermove
- onPointerUp
function() - Call like pointerup, but without Event for performance reason
- onPanX
function(e: Event.X.Delta) - Call when panning horizontal
- onPanY
function(e: Event.Y.Delta) - Call when panning vertical
- onSwipeLeft
function(e: Event.X.Delta) - Call when swipe left
- onSwipeRight
function(e: Event.X.Delta) - Call when swipe right
- onSwipeUp
function(e: Event.Y.Delta) - Call when swipe up
- onSwipeDown
function(e: Event.Y.Delta) - Call when swipe down
Usage
const swipe = SwipeGesture({
onPanX: delta => console.log("pan x delta", delta)
});
yourDom.addEventListener("pointerdown", swipe.onStart);
yourDom.addEventListener("pointermove", swipe.onMove);
yourDom.addEventListener("pointerup", swipe.onEnd);
License
MIT