MCPcopy
hub / github.com/simstudioai/sim / snapPositionToGrid

Function snapPositionToGrid

apps/sim/lib/workflows/autolayout/utils.ts:46–57  ·  view source on GitHub ↗
(
  position: { x: number; y: number },
  gridSize: number | undefined
)

Source from the content-addressed store, hash-verified

44 * Returns the original position if gridSize is 0 or not provided.
45 */
46export function snapPositionToGrid(
47 position: { x: number; y: number },
48 gridSize: number | undefined
49): { x: number; y: number } {
50 if (!gridSize || gridSize <= 0) {
51 return position
52 }
53 return {
54 x: snapToGrid(position.x, gridSize),
55 y: snapToGrid(position.y, gridSize),
56 }
57}
58
59/**
60 * Snaps all node positions in a graph to grid positions and returns updated dimensions.

Callers 4

layoutGroupFunction · 0.90
snapNodesToGridFunction · 0.85

Calls 1

snapToGridFunction · 0.85

Tested by

no test coverage detected