resizes content for given node (or all) if shouldSizeToContent() is true
(delay = false, n: GridStackNode = undefined)
| 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 { |
no test coverage detected