kopia lustrzana https://github.com/Tldraw/Tldraw
17 wiersze
530 B
TypeScript
17 wiersze
530 B
TypeScript
import type { TLPointerInfo } from '@tldraw/core'
|
|
import type { Action } from 'state/constants'
|
|
import { getShapeUtils } from 'shapes'
|
|
import { mutables } from 'state/mutables'
|
|
|
|
export const eraseShapes: Action = (data, payload: TLPointerInfo) => {
|
|
const { previousPoint } = mutables
|
|
|
|
Object.values(data.page.shapes)
|
|
.filter((shape) => !shape.isGhost)
|
|
.forEach((shape) => {
|
|
if (getShapeUtils(shape).hitTestLineSegment(shape, previousPoint, mutables.currentPoint)) {
|
|
shape.isGhost = true
|
|
}
|
|
})
|
|
}
|