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

Method onEndMoving

src/gridstack.ts:2753–2798  ·  view source on GitHub ↗
(event: Event)

Source from the content-addressed store, hash-verified

2751
2752 /** called when the item stops moving/resizing */
2753 const onEndMoving = (event: Event) => {
2754 this.placeholder.remove();
2755 delete this.placeholder.gridstackNode;
2756 delete node._moving;
2757 delete node._resizing;
2758 delete node._event;
2759 delete node._lastTried;
2760 const widthChanged = node.w !== node._orig.w;
2761
2762 // if the item has moved to another grid, we're done here
2763 const target: GridItemHTMLElement = event.target as GridItemHTMLElement;
2764 if (!target.gridstackNode || target.gridstackNode.grid !== this) return;
2765
2766 node.el = target;
2767
2768 if (node._isAboutToRemove) {
2769 const grid = el.gridstackNode.grid;
2770 if (grid._gsEventHandler[event.type]) {
2771 grid._gsEventHandler[event.type](event, target);
2772 }
2773 grid.engine.nodes.push(node); // temp add it back so we can proper remove it next
2774 grid.removeWidget(el, true, true);
2775 } else {
2776 Utils.removePositioningStyles(target);
2777 if (node._temporaryRemoved) {
2778 // use last position we were at (not _orig as we may have pushed others and moved) and add it back
2779 this._writePosAttr(target, node);
2780 this.engine.addNode(node);
2781 } else {
2782 // move to new placeholder location
2783 this._writePosAttr(target, node);
2784 }
2785 this.triggerEvent(event, target);
2786 }
2787 // @ts-ignore
2788 this._extraDragRow = 0;// @ts-ignore
2789 this._updateContainerHeight();// @ts-ignore
2790 this._triggerChangeEvent();
2791
2792 this.engine.endUpdate();
2793
2794 if (event.type === 'resizestop') {
2795 if (Number.isInteger(node.sizeToContent)) node.sizeToContent = node.h; // new soft limit
2796 this.resizeToContentCheck(widthChanged, node); // wait for width animation if changed
2797 }
2798 }
2799
2800 dd.draggable(el, {
2801 start: onStartMoving,

Callers

nothing calls this directly

Calls 9

_writePosAttrMethod · 0.95
triggerEventMethod · 0.95
_triggerChangeEventMethod · 0.95
resizeToContentCheckMethod · 0.95
removeWidgetMethod · 0.80
addNodeMethod · 0.80
endUpdateMethod · 0.80

Tested by

no test coverage detected