useWheelToAdjust
A custom React hook that registers mouse wheel rotation from the user that start on the element
referenced by dragAreaRef
. This hook detects how fast the user is rotating the mouse wheel and
returns a value corresponding to the speed of the mouse wheel.
This custom hooks allows for creating UI elements that can be adjusted by using the mouse wheel, such as sliders, or values that change in response to user input.
This is a lower-level custom hook that is used by useSlider
and useDial
.
Example
Use the mouse wheel to change!
Scroll faster for coarse adjustments, and slower for fine adjustments
0.0
Usage
Props
dragAreaRef
(required) A RefObject
referencing a DOM element that functions as the
“active” area. Any dragging or sliding action that happens when the pointer is over this
element is registered as dragging the target.
sensitivity
Determines quickly the resulting value changes in response to the user dragging Higher sensitivity values result in smaller adjustments for the same dragging distance. Default value is 100.
measureVerticalDragging
Determines if this hook responds to horizontal or vertical dragging actions. Default is true.
dragTouches
For touch devices, specifies the number of touches that will register as dragging. Defaults to 2.
Returns
dragAdjust
A value corresponding to the current drag distance.
isDragAdjusting
True if the user is currently dragging.