ag-swipe-react
v1.0.1
Published
A React hook wrapper for a lightweight library to detect swipes on touchscreen devices.
Downloads
28
Maintainers
Readme
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>
}