MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / cancelDrag

Method cancelDrag

src/gridstack.ts:2381–2394  ·  view source on GitHub ↗

@internal call when drag (and drop) needs to be cancelled (Esc key)

()

Source from the content-addressed store, hash-verified

2379
2380 /** @internal call when drag (and drop) needs to be cancelled (Esc key) */
2381 public cancelDrag() {
2382 const n = this._placeholder?.gridstackNode;
2383 if (!n) return;
2384 if (n._isExternal) {
2385 // remove any newly inserted nodes (from outside)
2386 n._isAboutToRemove = true;
2387 this.engine.removeNode(n);
2388 } else if (n._isAboutToRemove) {
2389 // restore any temp removed (dragged over trash)
2390 GridStack._itemRemoving(n.el, false);
2391 }
2392
2393 this.engine.restoreInitial();
2394 }
2395
2396 /** @internal removes any drag&drop present (called during destroy) */
2397 protected _removeDD(el: DDElementHost): GridStack {

Callers 1

_keyEventMethod · 0.80

Calls 3

removeNodeMethod · 0.80
_itemRemovingMethod · 0.80
restoreInitialMethod · 0.80

Tested by

no test coverage detected