hosembafer / react-swipe-to-dismiss

Swipe to dismiss hook for notifications

Home Page:https://react-swipe-to-dismiss.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-swipe-to-dismiss

npm version npm downloads npm size commit activity license

Swipe to dismiss hook for notifications

Install via npm

npm install react-swipe-to-dismiss

or

yarn add react-swipe-to-dismiss

Features

  • Left and right direction
  • Touch support 📱 (desktop and mobile)

Usage

import { useSwipeToDismiss } from 'react-swipe-to-dismiss';

const MessageItem = () => {
  const ref = useRef();
  useSwipeToDismiss(ref, onDismiss, false, 50, 'right');

  return (
    <div className="Message" ref={ref}>
      Your changes has been saved.
    </div>
  );
}

Props

  • onDismiss - function. If a component swiped more than its width then it will be called.
  • distanceBeforeDismiss - number. Distance in pixels from where lib will trigger onDismiss
  • removeDOM - boolean. Remove from DOM when element reaches distanceBeforeDismiss
  • direction - enum(left, right). In which direction user can swipe the element

About

Swipe to dismiss hook for notifications

https://react-swipe-to-dismiss.netlify.app/

License:Apache License 2.0


Languages

Language:JavaScript 67.4%Language:HTML 23.6%Language:CSS 9.0%