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

Method _setupRemoveDrop

src/gridstack.ts:2692–2706  ·  view source on GitHub ↗

@internal called to setup a trash drop zone if the user specifies it

()

Source from the content-addressed store, hash-verified

2690
2691 /** @internal called to setup a trash drop zone if the user specifies it */
2692 protected _setupRemoveDrop(): GridStack {
2693 if (typeof this.opts.removable !== 'string') return this;
2694 const trashEl = document.querySelector(this.opts.removable) as HTMLElement;
2695 if (!trashEl) return this;
2696
2697 // only register ONE static drop-over/dropout callback for the 'trash', and it will
2698 // update the passed in item and parent grid because the '.trash' is a shared resource anyway,
2699 // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)
2700 if (!this.opts.staticGrid && !dd.isDroppable(trashEl)) {
2701 dd.droppable(trashEl, this.opts.removableOptions)
2702 .on(trashEl, 'dropover', (event, el) => GridStack._itemRemoving(el, true))
2703 .on(trashEl, 'dropout', (event, el) => GridStack._itemRemoving(el, false));
2704 }
2705 return this;
2706 }
2707
2708 /**
2709 * prepares the element for drag&drop - this is normally called by makeWidget() unless are are delay loading

Callers 2

constructorMethod · 0.95
setStaticMethod · 0.95

Calls 4

isDroppableMethod · 0.80
droppableMethod · 0.80
_itemRemovingMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected