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

Method willItFit

src/gridstack-engine.ts:894–912  ·  view source on GitHub ↗

return true if can fit in grid height constrain only (always true if no maxRow)

(node: GridStackNode)

Source from the content-addressed store, hash-verified

892
893 /** return true if can fit in grid height constrain only (always true if no maxRow) */
894 public willItFit(node: GridStackNode): boolean {
895 delete node._willFitPos;
896 if (!this.maxRow) return true;
897 // create a clone with NO maxRow and check if still within size
898 const clone = new GridStackEngine({
899 column: this.column,
900 float: this.float,
901 nodes: this.nodes.map(n => {return {...n}})
902 });
903 const n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687
904 this.cleanupNode(n);
905 delete n.el; delete n._id; delete n.content; delete n.grid;
906 clone.addNode(n);
907 if (clone.getRow() <= this.maxRow) {
908 node._willFitPos = Utils.copyPos({}, n);
909 return true;
910 }
911 return false;
912 }
913
914 /** true if x,y or w,h are different after clamping to min/max */
915 public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {

Callers

nothing calls this directly

Calls 4

cleanupNodeMethod · 0.95
addNodeMethod · 0.95
getRowMethod · 0.95
copyPosMethod · 0.80

Tested by

no test coverage detected