Skip to content

snap beta ​

Function of @v12-engine/client

ts
export declare function snap(moving: Box, dx: number, dy: number, others: readonly Box[], view: {
    width: number;
    height: number;
}, options?: {
    reach?: number;
    margin?: number;
}): {
    dx: number;
    dy: number;
};

How far to move a box that is being moved by (dx, dy), for it to snap: an edge within reach of an edge of the screen (kept margin in), or of another box (next to it, or lined up with it), goes to it