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

Function releaseDrag

src/handlers/editorFileTab.js:194–232  ·  view source on GitHub ↗

* Cancels the drag * @param {MouseEvent} e

(e)

Source from the content-addressed store, hash-verified

192 * @param {MouseEvent} e
193 */
194function releaseDrag(e) {
195 const { clientX, clientY } = getClientPos(e);
196
197 /**@type {HTMLDivElement} target tab */
198 const $target = document.elementFromPoint(clientX, clientY);
199 const shouldCommitReorder = $parent.contains($target);
200
201 if (shouldCommitReorder) {
202 updateDragPreview(clientX, clientY);
203 if (didReorder) {
204 updateFileList($parent);
205 }
206 } else if (
207 $target &&
208 ($target.tagName === "INPUT" ||
209 $target.tagName === "TEXTAREA" ||
210 $target.isContentEditable ||
211 $target.closest(".cm-editor"))
212 ) {
213 // If released on an input area or CodeMirror editor
214 const filePath = editorManager.activeFile.uri;
215 if (filePath) {
216 if ($target.closest(".cm-editor")) {
217 const view = editorManager.editor;
218 view.dispatch(view.state.replaceSelection(filePath));
219 } else {
220 $target.value += filePath;
221 }
222 }
223 }
224
225 const shouldSettleClone = shouldCommitReorder || didReorder;
226
227 if (!shouldCommitReorder && didReorder) {
228 restoreInitialTabPosition();
229 }
230
231 finishDrag(shouldSettleClone);
232}
233
234function finishDrag(shouldSettleClone) {
235 cancelAnimationFrame(animationFrame);

Callers

nothing calls this directly

Calls 5

getClientPosFunction · 0.85
updateDragPreviewFunction · 0.85
updateFileListFunction · 0.85
finishDragFunction · 0.85

Tested by

no test coverage detected