MCPcopy
hub / github.com/e-oj/Magic-Grid / setup

Method setup

src/index.js:114–131  ·  view source on GitHub ↗

* Initializes an array of empty columns * and calculates the leftover whitespace. * * @return {{cols: Array, wSpace: number}} * @private

()

Source from the content-addressed store, hash-verified

112 * @private
113 */
114 setup () {
115 let width = this.container.getBoundingClientRect().width;
116 let colWidth = this.colWidth();
117 let numCols = Math.floor(width/colWidth) || 1;
118 let cols = [];
119
120 if (this.maxColumns && numCols > this.maxColumns) {
121 numCols = this.maxColumns;
122 }
123
124 for (let i = 0; i < numCols; i++) {
125 cols[i] = {height: 0, index: i};
126 }
127
128 let wSpace = width - numCols * colWidth + this.gutter;
129
130 return {cols, wSpace};
131 }
132
133 /**
134 * Gets the next available column.

Callers 1

positionItemsMethod · 0.95

Calls 1

colWidthMethod · 0.95

Tested by

no test coverage detected