2.0.3 • Published 2 years ago

react-swipe-to-dismiss v2.0.3

Weekly downloads
39
License
Apache-2.0
Repository
github
Last release
2 years ago

react-swipe-to-dismiss

npm version npm downloads npm size

Swipe to dismiss hook for notifications

Demo

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
1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.1.2

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

0.4.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

0.3.4

5 years ago

0.3.2

5 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.8

6 years ago