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

Method resizeToContentCheck

src/gridstack.ts:2064–2085  ·  view source on GitHub ↗

resizes content for given node (or all) if shouldSizeToContent() is true

(delay = false, n: GridStackNode = undefined)

Source from the content-addressed store, hash-verified

2062
2063 /** resizes content for given node (or all) if shouldSizeToContent() is true */
2064 private resizeToContentCheck(delay = false, n: GridStackNode = undefined) {
2065 if (!this.engine) return; // we've been deleted in between!
2066
2067 // update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
2068 // TODO: is there a way to know what the final (post animation) size of the content will be so we can animate the column width and height together rather than sequentially ?
2069 if (delay && this.hasAnimationCSS()) return setTimeout(() => this.resizeToContentCheck(false, n), this.animationDelay);
2070
2071 if (n) {
2072 if (Utils.shouldSizeToContent(n)) this.resizeToContentCBCheck(n.el);
2073 } else if (this.engine.nodes.some(n => Utils.shouldSizeToContent(n))) {
2074 const nodes = [...this.engine.nodes]; // in case order changes while resizing one
2075 this.batchUpdate();
2076 nodes.forEach(n => {
2077 if (Utils.shouldSizeToContent(n)) this.resizeToContentCBCheck(n.el);
2078 });
2079 this._ignoreLayoutsNodeChange = true; // loop through each node will set/reset around each move, so set it here again
2080 this.batchUpdate(false);
2081 this._ignoreLayoutsNodeChange = false;
2082 }
2083 // call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
2084 if (this._gsEventHandler['resizecontent']) this._gsEventHandler['resizecontent'](null, n ? [n] : this.engine.nodes);
2085 }
2086
2087 /** add or remove the grid element size event handler */
2088 protected _updateResizeEvent(forceRemove = false): GridStack {

Callers 8

makeSubGridMethod · 0.95
cellHeightMethod · 0.95
columnMethod · 0.95
updateMethod · 0.95
_prepareElementMethod · 0.95
onResizeMethod · 0.95
_setupAcceptWidgetMethod · 0.95
onEndMovingMethod · 0.95

Calls 4

hasAnimationCSSMethod · 0.95
batchUpdateMethod · 0.95
shouldSizeToContentMethod · 0.80

Tested by

no test coverage detected