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

editor

Public readonly property

Signature
readonly editor: Editor
References

Editor


Methods

clear()

Public method

Signature
clear(): void

getCurrentCommonAncestor()

Public method

Signature
getCurrentCommonAncestor(): TLShapeId | undefined
References

TLShapeId


getLines()

Public method

Signature
getLines(): SnapLine[]
References

SnapLine


getOutlinesInPageSpace()

Public method

Signature
getOutlinesInPageSpace(): Vec[][]
References

Vec


getSnappablePoints()

Public method

Signature
getSnappablePoints(): SnapPoint[]
References

SnapPoint


getSnappableShapes()

Public method

Signature
getSnappableShapes(): GapNode[]

getSnappingHandleDelta()

Public method

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

{ handlePoint, additionalSegments, }

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

Vec


getSnapPointsCache()

Public method

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

ComputedCache, SnapPoint, TLShape


getSnapThreshold()

Public method

Signature
getSnapThreshold(): number

getVisibleGaps()

Public method

Signature
getVisibleGaps(): {
  horizontal: Gap[]
  vertical: Gap[]
}

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: Box
  dragDelta: Vec
  handle: SelectionCorner | SelectionEdge
  isAspectRatioLocked: boolean
  isResizingFromCenter: boolean
}): SnapData
Parameters
NameDescription

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

{
  initialSelectionPageBounds: Box
  dragDelta: Vec
  handle: SelectionCorner | SelectionEdge
  isAspectRatioLocked: boolean
  isResizingFromCenter: boolean
}
Returns
SnapData
References

Box, Vec, SelectionCorner, SelectionEdge


snapTranslate()

Public method

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

{ lockedAxis, initialSelectionPageBounds, initialSelectionSnapPoints, dragDelta, }

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

SnapPoint, Box, Vec


SnapLineSnapPoint