useLongPress
Detect touch or pointer hold gestures.
useLongPress.tsx
import { useState } from "react";import { useLongPress } from "@cermuel/hooks/react";export function useLongPressExample() { const [pressed, setPressed] = useState(false); const press = useLongPress(() => setPressed(true)); return <button type="button" {...press.bind}>{pressed ? "Pressed" : "Hold"}</button>;}Props
Param
Type
Default Value
handler() => voidoptions?LongPressOptions{}Returns
{ bind: { onPointerDown: () => void; onPointerUp: () => void; onPointerLeave: () => void; onPointerCancel: () => void; }; start: () => void; cancel: () => void; }