Skip to main content

Home > @jsplumbtoolkit/core > AbstractLayout > snapToGrid

AbstractLayout.snapToGrid() method

Uses the magnetizer to snap either all the elements in the layout, or a single element, to a grid.

Signature:

snapToGrid(grid: Grid, elementId?: string): Record<string, {
original: PointXY;
current: PointXY;
}>;

Parameters

ParameterTypeDescription
gridGridDefinition of the grid to snap to.
elementIdstringIf provided, only this element will be snapped to the grid.

Returns:

Record<string, { original: PointXY; current: PointXY; }>