Table of contents

Public class

Signature
class SnapManager {}
Source

packages/editor/src/lib/editor/managers/SnapManager.ts


Constructor

Public constructor

Constructs a new instance of the SnapManager class

Parameters
NameDescription

editor

Editor
References

Editor


Properties

currentCommonAncestor

Public readonly property

Signature
get currentCommonAncestor(): TLShapeId | undefined
References

TLShapeId


editor

Public readonly property

Signature
readonly editor: Editor
References

Editor


lines

Public readonly property

Signature
get lines(): SnapLine[]
References

SnapLine


outlinesInPageSpace

Public readonly property

Signature
get outlinesInPageSpace(): Vec2d[][]
References

Vec2d


snappablePoints

Public readonly property

Signature
get snappablePoints(): SnapPoint[]
References

SnapPoint


snappableShapes

Public readonly property

Signature
get snappableShapes(): GapNode[]

snapPointsCache

Public readonly property

Signature
get snapPointsCache(): import('@tldraw/store').ComputedCache<
  SnapPoint[],
  TLShape
>
References

ComputedCache, SnapPoint, TLShape


snapThreshold

Public readonly property

Signature
get snapThreshold(): number

visibleGaps

Public readonly property

Signature
get visibleGaps(): {
  horizontal: Gap[]
  vertical: Gap[]
}

Methods

clear()

Public method

Signature
clear(): void

getSnappingHandleDelta()

Public method

Signature
getSnappingHandleDelta({
  handlePoint,
  additionalSegments,
}: {
  handlePoint: Vec2d
  additionalSegments: Vec2d[][]
}): null | Vec2d
Parameters
NameDescription

{ handlePoint, additionalSegments, }

{
  handlePoint: Vec2d
  additionalSegments: Vec2d[][]
}
Returns
null | Vec2d
References

Vec2d


setLines()

Public method

Signature
setLines(lines: SnapLine[]): void
Parameters
NameDescription

lines

SnapLine[]
Returns
void
References

SnapLine


snapResize()

Public method

Signature
snapResize({
  initialSelectionPageBounds,
  dragDelta,
  handle: originalHandle,
  isAspectRatioLocked,
  isResizingFromCenter,
}: {
  initialSelectionPageBounds: Box2d
  dragDelta: Vec2d
  handle: SelectionCorner | SelectionEdge
  isAspectRatioLocked: boolean
  isResizingFromCenter: boolean
}): SnapData
Parameters
NameDescription

{ initialSelectionPageBounds, dragDelta, handle: originalHandle, isAspectRatioLocked, isResizingFromCenter, }

{
  initialSelectionPageBounds: Box2d
  dragDelta: Vec2d
  handle: SelectionCorner | SelectionEdge
  isAspectRatioLocked: boolean
  isResizingFromCenter: boolean
}
Returns
SnapData
References

Box2d, Vec2d, SelectionCorner, SelectionEdge


snapTranslate()

Public method

Signature
snapTranslate({
  lockedAxis,
  initialSelectionPageBounds,
  initialSelectionSnapPoints,
  dragDelta,
}: {
  lockedAxis: 'x' | 'y' | null
  initialSelectionSnapPoints: SnapPoint[]
  initialSelectionPageBounds: Box2d
  dragDelta: Vec2d
}): SnapData
Parameters
NameDescription

{ lockedAxis, initialSelectionPageBounds, initialSelectionSnapPoints, dragDelta, }

{
  lockedAxis: 'x' | 'y' | null
  initialSelectionSnapPoints: SnapPoint[]
  initialSelectionPageBounds: Box2d
  dragDelta: Vec2d
}
Returns
SnapData
References

SnapPoint, Box2d, Vec2d


SnapLineSnapPoint