@tpguy825/clicker
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

clicker

Mouse event helper library for React

Examples

import { useLongPress, useLongHover } from "@tpguy825/clicker";
// or for preact
import { useLongPress, useLongHover } from "@tpguy825/clicker/preact";

function App() {
    const handlers = useLongPress(
        () => console.log("long press"),
        () => console.log("short press (click)"),
        { shouldPreventDefault: false, interval: 100 /* 0.1s */ },
    );

    return <button {...handlers}>Click me (then check the console)</button>;
}

function App() {
    const [hoveredForTime, handlers] = useLongHover(500);

    return <button {...handlers}>{hoveredForTime ? "You hovered for 0.5s!" : "Hover over me!"}</button>;
}

Package Sidebar

Install

npm i @tpguy825/clicker

Weekly Downloads

56

Version

1.1.0

License

ISC

Unpacked Size

17 kB

Total Files

12

Last publish

Collaborators

  • tpguy825