kopia lustrzana https://github.com/Tldraw/Tldraw
24 wiersze
546 B
TypeScript
24 wiersze
546 B
TypeScript
import { Editor, HIT_TEST_MARGIN, TLShape } from '@tldraw/editor'
|
|
|
|
export function getHitShapeOnCanvasPointerDown(
|
|
editor: Editor,
|
|
hitLabels = false
|
|
): TLShape | undefined {
|
|
const zoomLevel = editor.getZoomLevel()
|
|
const {
|
|
inputs: { currentPagePoint },
|
|
} = editor
|
|
|
|
return (
|
|
// hovered shape at point
|
|
editor.getShapeAtPoint(currentPagePoint, {
|
|
hitInside: false,
|
|
hitLabels,
|
|
margin: HIT_TEST_MARGIN / zoomLevel,
|
|
renderingOnly: true,
|
|
}) ??
|
|
// selected shape at point
|
|
editor.getSelectedShapeAtPoint(currentPagePoint)
|
|
)
|
|
}
|