use-move
Handles move behavior over any element, use to build custom sliders, color pickers, etc.
Import
Source
Docs
Package
Usage
use-move handles move behavior over any element:
Values
{ x: 20, y: 60 }
API
Hook accepts callback that is called when user moves pressed mouse over given element and returns object with ref
and active state:
x
and y
values are always between 0
and 1
, you can use them to calculate value in your boundaries.
Examples
Horizontal slider
You can ignore changes for one of the axis:
Value: 20
Vertical slider
Moving slider down increases value, to reverse that set value to 1 - y
in your setValue
function:
Value: 20