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
Parameter | Type | Description |
---|---|---|
el | string | Vertex | Element | ID of vertex, Vertex, or DOM element representing a Vertex. |
grid | Grid | Optional 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