0.0.6 • Published 5 years ago

@dalisoft/swipe-gesture v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

swipe-gesture

Greenkeeper badge

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 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

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago