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

Function onMove

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

Source from the content-addressed store, hash-verified

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