@1ohooks/swipeable
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@1ohooks/swipeable

Version Coverage Status Downloads Try on RunKit

The @1ohooks/swipeable package provides hooks for handling swipe gestures in React applications.

Installation

Install the package with:

npm install @1ohooks/swipeable
# or
yarn add @1ohooks/swipeable

Documentation

useHorizontalSwipeMinimum

The useHorizontalSwipeMinimum hook allows you to detect horizontal swipe gestures.

import { useHorizontalSwipeMinimum } from '@1ohooks/swipeable';

// Usage example
function MyComponent() {
  useHorizontalSwipeMinimum(50, () => {
    // Handle swipe left
  }, () => {
    // Handle swipe right
  });

  return (
    // Your component JSX
  );
}

useVerticalSwipeMinimum

The useVerticalSwipeMinimum hook allows you to detect vertical swipe gestures.

import { useVerticalSwipeMinimum } from '@1ohooks/swipeable';

// Usage example
function MyComponent() {
  useVerticalSwipeMinimum(50, () => {
    // Handle swipe up
  }, () => {
    // Handle swipe down
  });

  return (
    // Your component JSX
  );
}

useSwipe

The useSwipe hook provides a more versatile way to handle swipe gestures with customizable options.

import { useSwipe } from '@1ohooks/swipeable';

// Usage example
function MyComponent() {
  const { swipeDistance } = useSwipe({
    threshold: 50,
    onSwipeLeft: () => {
      // Handle swipe left
    },
    onSwipeRight: () => {
      // Handle swipe right
    },
    // Additional configuration options
  });

  return (
    // Your component JSX
  );
}

Requirements

  • React 16 or higher.

Usage

You can easily integrate the swipe gestures into your React components by importing and using the provided hooks.

For more advanced usage and configuration options, refer to the individual hook documentation.

Readme

Keywords

none

Package Sidebar

Install

npm i @1ohooks/swipeable

Weekly Downloads

0

Version

0.1.3

License

ISC

Unpacked Size

4.67 kB

Total Files

6

Last publish

Collaborators

  • 1ojames