@dalisoft/swipe-gesture
v0.0.6
Published
Swipe gesture library
Downloads
19
Maintainers
Readme
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
// Node.js
const SwipeGesture = require("@dalisoft/swipe-gesture");
// Browser
// window.SwipeGesture OR SwipeGesture
// ES6
import SwipeGesture from "@dalisoft/swipe-gesture";
Parameters
- onPointerDown
function(e: Event)
- Call likepointerdown
- onPointerMove
function(e: Event)
- Call likepointermove
- onPointerUp
function()
- Call likepointerup
, but withoutEvent
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