@mocanvas/editor · class

BoundsSnaps

declare class BoundsSnaps

Bounds snapping: aligning a dragged or resized selection's edges and centres with those of the shapes around it.

Reached as editor.snaps.shapeBounds.


Methods · 4

constructor(manager: SnapManager)
getSnapPoints(shapeId: ShapeId): BoundsSnapPoint[]

The page-space points a shape offers as snap targets.

A shape util may name its own through getBoundsSnapGeometry; a shape that names none contributes its four corners and its centre, which is what almost every shape wants. A util that returns an *empty* list is saying something different — that it should not be snapped to at all.

snapResizeShapes({ initialSelectionPageBounds, dragDelta, handle, isAspectRatioLocked, isResizingFromCenter, }: BoundsSnapResizeOptions): SnapData

Snap a resize. Only the edges the handle actually moves are considered, so a bottom-right drag never nudges the top-left corner.

snapTranslateShapes({ initialSelectionPageBounds, dragDelta, lockedAxis, }: BoundsSnapTranslateOptions): SnapData

Snap a translation. Returns the extra nudge to add to dragDelta, and publishes the indicators that explain it.


Properties · 2

readonly editor: Editor
readonly manager: SnapManager

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.