MCPcopy Index your code
hub / github.com/SortableJS/Sortable / _handleAutoScroll

Function _handleAutoScroll

plugins/AutoScroll/AutoScroll.js:98–144  ·  view source on GitHub ↗
(evt, fallback)

Source from the content-addressed store, hash-verified

96 },
97
98 _handleAutoScroll(evt, fallback) {
99 const x = (evt.touches ? evt.touches[0] : evt).clientX,
100 y = (evt.touches ? evt.touches[0] : evt).clientY,
101
102 elem = document.elementFromPoint(x, y);
103
104 touchEvt = evt;
105
106 // IE does not seem to have native autoscroll,
107 // Edge's autoscroll seems too conditional,
108 // MACOS Safari does not have autoscroll,
109 // Firefox and Chrome are good
110 if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
111 autoScroll(evt, this.options, elem, fallback);
112
113 // Listener for pointer element change
114 let ogElemScroller = getParentAutoScrollElement(elem, true);
115 if (
116 scrolling &&
117 (
118 !pointerElemChangedInterval ||
119 x !== lastAutoScrollX ||
120 y !== lastAutoScrollY
121 )
122 ) {
123 pointerElemChangedInterval && clearPointerElemChangedInterval();
124 // Detect for pointer elem change, emulating native DnD behaviour
125 pointerElemChangedInterval = setInterval(() => {
126 let newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
127 if (newElem !== ogElemScroller) {
128 ogElemScroller = newElem;
129 clearAutoScrolls();
130 }
131 autoScroll(evt, this.options, newElem, fallback);
132 }, 10);
133 lastAutoScrollX = x;
134 lastAutoScrollY = y;
135 }
136 } else {
137 // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
138 if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
139 clearAutoScrolls();
140 return;
141 }
142 autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
143 }
144 }
145 };
146
147 return Object.assign(AutoScroll, {

Callers

nothing calls this directly

Calls 4

clearAutoScrollsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…