Home > @jsplumbtoolkit/browser-ui > snapToGrid
snapToGrid() function
Snap the given x,y to a point on the grid defined by gridX and gridY, using the given thresholds to calculate proximity to the grid.
Signature:
export declare function snapToGrid(pos: PointXY, grid: Grid, thresholdX?: number, thresholdY?: number): PointXY;
Parameters
Parameter | Type | Description |
---|---|---|
pos | PointXY | Position to transform |
grid | Grid | Definition of the grid |
thresholdX | number | Defines how close to a grid line in the x axis a value must be in order to be snapped to it. |
thresholdY | number | Defines how close to a grid line in the y axis a value must be in order to be snapped to it. |
Returns:
The point to which the position was snapped, given the constraints of the grid.