MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / onDrag

Function onDrag

src/handlers/editorFileTab.js:159–188  ·  view source on GitHub ↗

* On mouse or touch move * @param {MouseEvent|TouchEvent} e * @returns

(e)

Source from the content-addressed store, hash-verified

157 * @returns
158 */
159function onDrag(e) {
160 if (e instanceof Event) {
161 e.preventDefault();
162 e.stopPropagation();
163 e.stopImmediatePropagation();
164 }
165
166 const { clientX, clientY } = getClientPos(e);
167
168 tabLeft = clientX - offsetX;
169 tabTop = clientY - offsetY;
170
171 $tabClone.style.transform = `translate3d(${tabLeft}px, ${tabTop}px, 0)`;
172 updateDragPreview(clientX, clientY);
173
174 if ($parent.scrollWidth === $parent.clientWidth) return;
175
176 const scroll = getScroll();
177 // if can scroll and already scrolling return
178 // or if can't scroll and not scrolling return
179 if (!!scroll === !!animationFrame) return;
180 // if can't scroll and scrolling clear interval
181 if (!scroll && animationFrame) {
182 cancelAnimationFrame(animationFrame);
183 animationFrame = null;
184 return;
185 }
186
187 scrollContainer();
188}
189
190/**
191 * Cancels the drag

Callers

nothing calls this directly

Calls 6

getClientPosFunction · 0.85
updateDragPreviewFunction · 0.85
getScrollFunction · 0.85
scrollContainerFunction · 0.85
preventDefaultMethod · 0.45
stopPropagationMethod · 0.45

Tested by

no test coverage detected