npm.io
1.0.2 • Published 4 years ago

ag-swipe-core

Licence
ISC
Version
1.0.2
Deps
1
Size
4 kB
Vulns
0
Weekly
0

For more details on the public interface of the library please see the Github page.

Installation

npm install ag-swipe-core --save

Usage

import { createSwipeSubscription, SwipeEvent } from 'ag-swipe-core';

const domElement: HTMLElement = document.querySelector('#swipe-element');

const swipeSubscription = createSwipeSubscription({
  domElement,
  onSwipeEnd: (event: SwipeEvent) => {
    console.log(`SwipeEnd direction: ${event.direction} and distance: ${event.distance}`);
  },
});

Unsubscribing

When swipe events should no longer be tracked:

if (swipeSubscription) {
  swipeSubscription.unsubscribe();
}

Keywords