feat(react): orientation-aware buffer styling and slider improvements (#671)

This commit is contained in:
Sam Potts
2026-03-02 11:40:58 +11:00
committed by GitHub
parent e3d7f4b277
commit 86b2f4d3b4
8 changed files with 68 additions and 22 deletions
+8 -8
View File
@@ -84,20 +84,20 @@ export function useSlider<State extends SliderState = SliderState>(
// Cleanup on unmount.
useEffect(() => () => slider.destroy(), [slider]);
// Force a synchronous re-render after mount so edge thumb alignment
// can read DOM measurements from the now-populated element refs.
useLayoutEffect(() => {
if (rootElementRef.current && thumbElementRef.current) {
forceRender();
}
}, []);
// Subscribe to interaction state.
const interaction = useSnapshot(slider.interaction);
// Compute derived state from interaction + caller-provided projection.
const state = options.computeState(interaction);
// Force a synchronous re-render after mount so edge thumb alignment
// can read DOM measurements from the now-populated element refs.
useLayoutEffect(() => {
if (state.thumbAlignment === 'edge' && rootElementRef.current && thumbElementRef.current) {
forceRender();
}
}, [state.thumbAlignment]);
// Adjust CSS var percents for edge thumb alignment when DOM elements are available.
const rootEl = rootElementRef.current;
const thumbEl = thumbElementRef.current;