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

Function move

packages/react-aria/src/dnd/useAutoScroll.ts:78–108  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

76
77 return {
78 move(x, y) {
79 // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).
80 // https://bugs.webkit.org/show_bug.cgi?id=222636
81 if (!isWebKit() || isIOS() || !scrollableRef.current) {
82 return;
83 }
84
85 let box = scrollableRef.current.getBoundingClientRect();
86 let left = AUTOSCROLL_AREA_SIZE;
87 let top = AUTOSCROLL_AREA_SIZE;
88 let bottom = box.height - AUTOSCROLL_AREA_SIZE;
89 let right = box.width - AUTOSCROLL_AREA_SIZE;
90 if (x < left || x > right || y < top || y > bottom) {
91 if (x < left) {
92 state.dx = x - left;
93 } else if (x > right) {
94 state.dx = x - right;
95 }
96 if (y < top) {
97 state.dy = y - top;
98 } else if (y > bottom) {
99 state.dy = y - bottom;
100 }
101
102 if (!state.timer) {
103 state.timer = requestAnimationFrame(scroll);
104 }
105 } else {
106 this.stop();
107 }
108 },
109 stop() {
110 if (state.timer) {
111 cancelAnimationFrame(state.timer);

Callers 4

ColorArea.test.tsxFile · 0.50

Calls 1

stopMethod · 0.65

Tested by

no test coverage detected