| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import {
- hasExceededDragThreshold,
- normalizeCoordinate
- } from '@/components/mt-dzr/utils/drag-position'
- type LinePoint = {
- x: number
- y: number
- }
- type LineBinfo = {
- left: number
- top: number
- width: number
- height: number
- }
- export const hasLineDragStarted = (deltaX: number, deltaY: number) =>
- hasExceededDragThreshold(deltaX, deltaY)
- export const normalizeLineGeometry = (binfo: LineBinfo, points: LinePoint[]) => ({
- binfo: {
- left: normalizeCoordinate(binfo.left),
- top: normalizeCoordinate(binfo.top),
- width: normalizeCoordinate(binfo.width),
- height: normalizeCoordinate(binfo.height)
- },
- points: points.map((point) => ({
- x: normalizeCoordinate(point.x),
- y: normalizeCoordinate(point.y)
- }))
- })
- export const completeLineEdit = <T>(
- value: T,
- changed: boolean,
- update: (value: T) => void,
- complete: () => void
- ) => {
- if (!changed) {
- return
- }
- update(value)
- complete()
- }
|