Skip to main content

Home > @jsplumbtoolkit/browser-ui > Surface > snapToGrid

Surface.snapToGrid() method

Snaps one or all vertices to the current grid or to the grid provided to this method.

Signature:

snapToGrid(el?: string | Vertex | Element, grid?: Grid): Record<string, {
original: PointXY;
current: PointXY;
}> | null;

Parameters

ParameterTypeDescription
elstring | Vertex | ElementID of vertex, Vertex, or DOM element representing a Vertex.
gridGridOptional grid to snap to. If not provided, the Surface will use the grid passed in to its constructor. If that is also null, nothing will be snapped.

Returns:

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