Swipe gesture library
npm install @dalisoft/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_
- No limit: not only for DOM
- Handles types for your
- Clean code
- Simple & Easy
- Performant
- UMD compatible
We recommend install via npm because of it's cache and flat node modules tree
``bash`
npm i @dalisoft/swipe-gesture
then you able to import to Node.js/Browser easily
`js
// Node.js
const SwipeGesture = require("@dalisoft/swipe-gesture");
// Browser
// window.SwipeGesture OR SwipeGesture
// ES6
import SwipeGesture from "@dalisoft/swipe-gesture";
`
- _onPointerDown_ function(e: Event) - Call like pointerdownfunction(e: Event)
- _onPointerMove_ - Call like pointermovefunction()
- _onPointerUp_ - Call like pointerup, but without Event for performance reasonfunction(e: Event.X.Delta)
- _onPanX_ - Call when panning horizontalfunction(e: Event.Y.Delta)
- _onPanY_ - Call when panning verticalfunction(e: Event.X.Delta)
- _onSwipeLeft_ - Call when swipe leftfunction(e: Event.X.Delta)
- _onSwipeRight_ - Call when swipe rightfunction(e: Event.Y.Delta)
- _onSwipeUp_ - Call when swipe upfunction(e: Event.Y.Delta)
- _onSwipeDown_ - Call when swipe down
`js
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);
``
MIT