MCPcopy
hub / github.com/react-grid-layout/react-grid-layout / calcWHRaw

Function calcWHRaw

src/core/calculate.ts:276–296  ·  view source on GitHub ↗
(
  positionParams: PositionParams,
  width: number,
  height: number
)

Source from the content-addressed store, hash-verified

274 * @returns w, h in grid units (unclamped, minimum 1)
275 */
276export function calcWHRaw(
277 positionParams: PositionParams,
278 width: number,
279 height: number
280): { w: number; h: number } {
281 const { margin, rowHeight } = positionParams;
282 const colWidth = calcGridColWidth(positionParams);
283
284 // width = colWidth * w - (margin * (w - 1))
285 // w = (width + margin) / (colWidth + margin)
286 const w = Math.max(
287 1,
288 Math.round((width + margin[0]) / (colWidth + margin[0]))
289 );
290 const h = Math.max(
291 1,
292 Math.round((height + margin[1]) / (rowHeight + margin[1]))
293 );
294
295 return { w, h };
296}
297
298// ============================================================================
299// Utility Functions

Callers 1

GridItemFunction · 0.85

Calls 1

calcGridColWidthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…