0.1.3 • Published 8 months ago

@1ohooks/swipeable v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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