react-swipe-hook
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.1.2](https://github.com/EricLambrecht/react-swipe-hook/compare/v0.1.1...v0.1.2) (2020-03-19) | ||
### Bug Fixes | ||
* Added missing documentation ([02dc862](https://github.com/EricLambrecht/react-swipe-hook/commit/02dc862e2630d55e775922022d7621a3f4ba123a)) | ||
### [0.1.1](https://github.com/EricLambrecht/react-swipe-hook/compare/v0.1.0...v0.1.1) (2020-03-19) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "react-swipe-hook", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A hook for running callbacks on swipe", | ||
@@ -5,0 +5,0 @@ "main": "dist/useSwipeCallback.js", |
# react-swipe-hook | ||
A hook for running callbacks on swipe | ||
## Api | ||
### Params | ||
1. `minimumDistance` | ||
2. `onSwipeUp` | ||
3. `onSwipeRight` | ||
4. `onSwipeDown` | ||
5. `onSwipeLeft` | ||
### Returns | ||
Array of `onTouchStart` and `onTouchEnd` event handlers. | ||
## Example usage | ||
```jsx harmony | ||
const ExampleComp = () => { | ||
const [output, setOutput] = useState('no output') | ||
const [onTouchStart, onTouchEnd] = useSwipeCallback( | ||
40, //the minimum swipe distance | ||
() => setOutput('The user swiped up!'), | ||
() => setOutput('The user swiped right!'), | ||
() => setOutput('The user swiped down!'), | ||
() => setOutput('The user swiped left!') | ||
) | ||
return ( | ||
<> | ||
<div | ||
data-testid="swipe-area" | ||
onTouchStart={onTouchStart} | ||
onTouchEnd={onTouchEnd} | ||
/> | ||
<div data-testid="test-output">{output}</div> | ||
</> | ||
) | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13931
42