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

Method _updateResizeEvent

src/gridstack.ts:2088–2106  ·  view source on GitHub ↗

add or remove the grid element size event handler

(forceRemove = false)

Source from the content-addressed store, hash-verified

2086
2087 /** add or remove the grid element size event handler */
2088 protected _updateResizeEvent(forceRemove = false): GridStack {
2089 // only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting dynamic column (i.e. doing work)
2090 // or supporting new sizeToContent option.
2091 const trackSize = !this.parentGridNode && (this._isAutoCellHeight || this.opts.sizeToContent || this.opts.columnOpts
2092 || this.engine.nodes.find(n => n.sizeToContent));
2093
2094 if (!forceRemove && trackSize && !this.resizeObserver) {
2095 this._sizeThrottle = Utils.throttle(() => this.onResize(), this.opts.cellHeightThrottle);
2096 this.resizeObserver = new ResizeObserver(() => this._sizeThrottle());
2097 this.resizeObserver.observe(this.el);
2098 this._skipInitialResize = true; // makeWidget will originally have called on startup
2099 } else if ((forceRemove || !trackSize) && this.resizeObserver) {
2100 this.resizeObserver.disconnect();
2101 delete this.resizeObserver;
2102 delete this._sizeThrottle;
2103 }
2104
2105 return this;
2106 }
2107
2108 /** @internal convert a potential selector into actual element */
2109 public static getElement(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement { return Utils.getElement(els) }

Callers 4

constructorMethod · 0.95
cellHeightMethod · 0.95
destroyMethod · 0.95
updateOptionsMethod · 0.95

Calls 3

onResizeMethod · 0.95
findMethod · 0.80
throttleMethod · 0.80

Tested by

no test coverage detected