Skip to content
pixi-silk
GitHub repository
Function

findSpacing

import { findSpacing } from 'pixi-silk/ui/spacing';
function findSpacing(
   moving: SnapRect, 
   others: readonly SnapRect[], 
   options?: FindSpacingOptions
): SpacingResult;

Smart spacing for a box being dragged among others. When the gap to a neighbour equals another gap in the same row or column, every one of those gaps is returned. Edges and centres that line up with other boxes come back as lines spanning them. Edges only match edges, centres only centres.

It only reports and never moves the box. Snap with a SnapEngine first, then call this on the snapped box. moving itself is skipped when it is also in others.

Parameters#

ParameterType
movingSnapRect
othersreadonly SnapRect[]
optionsFindSpacingOptions

Returns#

SpacingResult