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
Parameter | Type | Description |
---|---|---|
grid | Grid | Definition of the grid to snap to. |
elementId | string | If provided, only this element will be snapped to the grid. |
Returns:
Record<string, { original: PointXY; current: PointXY; }>