use-hammer
v1.0.0
Published
React Hooks for Long Press
Downloads
3
Maintainers
Readme
Install
npm install --save use-hammer
Usage
import React from 'react'
import useHammer from 'use-hammer'
const Example = () => {
const onHammer = useCallback(() => {
console.log('Long Press')
}, [])
const [hammerDown, hammerUp] = useHammer({onHammer, second:300})
return (
<div className={"sample-div"} onMouseDown={()=> hammerDown()} onMouseUp={() => hammerUp()}/>
)
}
API
useHammer
| Prop | Type | Required | Description |
| :--- | :--- | :------: | :---------- |
| onHammer
| Function | ✓ | Execute onHammer Function |
| second
| number | | [Default:700ms] Millisecond |
License
MIT © snyung
This hook is created using create-react-hook.