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

Method cacheRects

src/gridstack-engine.ts:287–298  ·  view source on GitHub ↗

* Cache the pixel rectangles for all nodes used for collision detection during drag operations. * This optimization converts grid coordinates to pixel coordinates for faster collision detection. * * @param w width of a single grid cell in pixels * @param h height of a single grid cell in

(w: number, h: number, top: number, right: number, bottom: number, left: number)

Source from the content-addressed store, hash-verified

285 * @internal This is typically called by GridStack during resize events
286 */
287 public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine
288 {
289 this.nodes.forEach(n =>
290 n._rect = {
291 y: n.y * h + top,
292 x: n.x * w + left,
293 w: n.w * w - left - right,
294 h: n.h * h - top - bottom
295 }
296 );
297 return this;
298 }
299
300 /**
301 * Attempt to swap the positions of two nodes if they meet swapping criteria.

Callers 2

_onStartMovingMethod · 0.80
_dragOrResizeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected