1.0.1 • Published 2 years ago

ag-swipe-react v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

This library is a React hook wrapper around the vanilla JS swipe detection library ag-swipe-core.

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

Installation

npm install ag-swipe-react --save

Usage

import { SwipeEvent, useSwipe } from 'ag-swipe-react';

export function App() {
  const swipeElement = useSwipe({
    onSwipeMove: (event: SwipeEvent) => {
      console.log(`SwipeMove direction: ${event.direction} and distance: ${event.distance}`);
    },
    onSwipeEnd: (event: SwipeEvent) => {
      console.log(`SwipeEnd direction: ${event.direction} and distance: ${event.distance}`);
    }
  });

  return <div ref={swipeElement}>Swipe me!</div>
}
1.0.1

2 years ago

1.0.0

2 years ago