Headless
useFader
Interaction for a custom fader.
useFader gives a Fader-style interaction to a view of your own: a vertical drag that moves the value relative to where it started. It takes the same props as the component, so a parameter or a standalone value both work.
import { useFader } from '@soundor/components/headless';
import { View } from '@soundor/react';
function CustomFader(props: RangeProps) {
const fader = useFader(props);
return (
<View {...fader.handlers} style={{ width: 28, height: 160 }}>
<Cap position={fader.normalized} />
</View>
);
}Defaults: axis: 'y', dragMode: 'relative'. The drag keeps its grab offset, so the handle does not jump to the pointer.
Returns
value,normalized,min,max,label,disabled: the control's current state.normalizedis0–1through the parameter's or thescalemapping.handlers: spread onto a focusable SoundorView. They supply pointer, wheel and keyboard input, and the accessibility role and value.hovered,focusVisible,pressed: interaction state for drawing.focusVisibleis true only for keyboard focus.
Parameters
useFader(props, options?)
props
Prop
Type
options
Prop
Type