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

Method cacheOneLayout

src/gridstack-engine.ts:1219–1231  ·  view source on GitHub ↗

* call to cache the given node layout internally to the given location so we can restore back when column changes size * @param node single node to cache * @param column corresponding column index to save it under

(n: GridStackNode, column: number)

Source from the content-addressed store, hash-verified

1217 * @param column corresponding column index to save it under
1218 */
1219 public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {
1220 n._id = n._id ?? GridStackEngine._idSeq++;
1221 const l: GridStackNode = {x: n.x, y: n.y, w: n.w, _id: n._id}
1222 if (n.autoPosition || n.x === undefined) { delete l.x; delete l.y; if (n.autoPosition) l.autoPosition = true; }
1223 this._layouts = this._layouts || [];
1224 this._layouts[column] = this._layouts[column] || [];
1225 const index = this.findCacheLayout(n, column);
1226 if (index === -1)
1227 this._layouts[column].push(l);
1228 else
1229 this._layouts[column][index] = l;
1230 return this;
1231 }
1232
1233 protected findCacheLayout(n: GridStackNode, column: number): number | undefined {
1234 return this._layouts?.[column]?.findIndex(l => l._id === n._id) ?? -1;

Callers 1

nodeBoundFixMethod · 0.95

Calls 1

findCacheLayoutMethod · 0.95

Tested by

no test coverage detected