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

Function move

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

Source from the content-addressed store, hash-verified

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

Callers 4

ColorArea.test.tsxFile · 0.50

Calls 1

stopMethod · 0.80

Tested by

no test coverage detected