react-swipe-to-dismiss

2.0.3 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.30latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.30
2.0.20
2.0.10
2.0.00
1.2.00
1.1.22
1.1.00
1.0.10
1.0.00
0.4.00
0.3.452
0.3.20
0.3.10
0.3.00
0.2.00
0.1.80

Package Sidebar

Install

npm i react-swipe-to-dismiss

Weekly Downloads

46

Version

2.0.3

License

Apache-2.0

Unpacked Size

29.2 kB

Total Files

11

Last publish

Collaborators

  • hosembafer