diff --git a/components/CanvasEditor.vue b/components/CanvasEditor.vue index 410578c..9f3bbb7 100644 --- a/components/CanvasEditor.vue +++ b/components/CanvasEditor.vue @@ -8,7 +8,22 @@ const rotation: Record = { right: "270" }; +interface ActionMap { + move: Position; + edit: string; + resize: string; +} +type Action = keyof ActionMap; +interface HistoryAction +{ + event: T; + element: number | number[]; + from: ActionMap[T]; + to: ActionMap[T]; +} + const cancelEvent = (e: Event) => e.preventDefault(); +const stopPropagation = (e: Event) => e.stopImmediatePropagation(); function center(touches: TouchList): Position { const pos = { x: 0, y: 0 }; @@ -28,38 +43,37 @@ function distance(touches: TouchList): number const [A, B] = touches; return Math.hypot(B.clientX - A.clientX, B.clientY - A.clientY); } +function contains(group: CanvasNode, node: CanvasNode): boolean +{ + return group.x < node.x && group.y < node.y && group.x + group.width > node.x + node.width && group.y + group.height > node.y + node.height; +} @@ -287,29 +400,7 @@ function resizeNode(e: MouseEvent, x: number, y: number) }" class="h-full">
-
-
-
-
- -
-
-
- - - - - - - - -
-
-
- -
-
{{ node.label }}
-
+