MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onMove

Function onMove

packages/react-aria/src/slider/useSlider.ts:86–108  ·  view source on GitHub ↗
({deltaX, deltaY})

Source from the content-addressed store, hash-verified

84 currentPosition.current = null;
85 },
86 onMove({deltaX, deltaY}) {
87 if (!trackRef.current) {
88 return;
89 }
90 let {height, width} = trackRef.current.getBoundingClientRect();
91 let size = isVertical ? height : width;
92
93 if (currentPosition.current == null && realTimeTrackDraggingIndex.current != null) {
94 currentPosition.current = state.getThumbPercent(realTimeTrackDraggingIndex.current) * size;
95 }
96
97 let delta = isVertical ? deltaY : deltaX;
98 if (isVertical || reverseX) {
99 delta = -delta;
100 }
101
102 currentPosition.current! += delta;
103
104 if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
105 const percent = clamp(currentPosition.current! / size, 0, 1);
106 state.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
107 }
108 },
109 onMoveEnd() {
110 if (realTimeTrackDraggingIndex.current != null) {
111 state.setThumbDragging(realTimeTrackDraggingIndex.current, false);

Callers 2

useMoveFunction · 0.50
useDroppableCollectionFunction · 0.50

Calls 3

clampFunction · 0.90
getThumbPercentMethod · 0.80
setThumbPercentMethod · 0.80

Tested by

no test coverage detected