@witchcraft/layout 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/FrameDragHandle.vue +3 -3
  3. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
  4. package/dist/runtime/components/LayoutDragEdgeHandle.d.vue.ts +2 -2
  5. package/dist/runtime/components/LayoutDragEdgeHandle.vue +2 -2
  6. package/dist/runtime/components/LayoutDragEdgeHandle.vue.d.ts +2 -2
  7. package/dist/runtime/components/LayoutDragEdges.vue +5 -5
  8. package/dist/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
  9. package/dist/runtime/components/LayoutFrame.vue +2 -2
  10. package/dist/runtime/components/LayoutIntersectionHandle.d.vue.ts +2 -2
  11. package/dist/runtime/components/LayoutIntersectionHandle.vue +2 -2
  12. package/dist/runtime/components/LayoutIntersectionHandle.vue.d.ts +2 -2
  13. package/dist/runtime/components/LayoutIntersections.vue +4 -4
  14. package/dist/runtime/components/LayoutWindow.d.vue.ts +44 -44
  15. package/dist/runtime/components/LayoutWindow.vue +27 -27
  16. package/dist/runtime/components/LayoutWindow.vue.d.ts +44 -44
  17. package/dist/runtime/composables/useFrames.d.ts +107 -109
  18. package/dist/runtime/composables/useFrames.js +107 -99
  19. package/dist/runtime/demo/App.vue +16 -16
  20. package/dist/runtime/demo/DemoControls.d.vue.ts +2 -2
  21. package/dist/runtime/demo/DemoControls.vue +4 -4
  22. package/dist/runtime/demo/DemoControls.vue.d.ts +2 -2
  23. package/dist/runtime/helpers/createZoneSideClipPath.d.ts +2 -2
  24. package/dist/runtime/helpers/{findFrameDraggableEdges.d.ts → findFrameMoveableEdges.d.ts} +2 -2
  25. package/dist/runtime/helpers/{findFrameDraggableEdges.js → findFrameMoveableEdges.js} +3 -3
  26. package/dist/runtime/helpers/{findDraggableEdge.d.ts → findMoveableEdge.d.ts} +1 -1
  27. package/dist/runtime/helpers/{findDraggableEdge.js → findMoveableEdge.js} +1 -1
  28. package/dist/runtime/helpers/index.d.ts +2 -2
  29. package/dist/runtime/helpers/index.js +2 -2
  30. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +1 -1
  31. package/dist/runtime/layout/createSplitDecoFromDrag.js +2 -2
  32. package/dist/runtime/layout/findSafeSplitEdge.d.ts +1 -1
  33. package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
  34. package/dist/runtime/layout/getCloseFrameInfo.js +4 -4
  35. package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +2 -2
  36. package/dist/runtime/layout/getFrameRearrangeInfo.js +8 -8
  37. package/dist/runtime/layout/getFrameSplitInfo.d.ts +1 -1
  38. package/dist/runtime/layout/getFrameSplitInfo.js +2 -2
  39. package/dist/runtime/layout/{getFrameDragZones.d.ts → getFrameZones.d.ts} +3 -3
  40. package/dist/runtime/layout/{getFrameDragZones.js → getFrameZones.js} +1 -1
  41. package/dist/runtime/layout/{getWindowDragZones.d.ts → getWindowZones.d.ts} +1 -1
  42. package/dist/runtime/layout/{getWindowDragZones.js → getWindowZones.js} +1 -1
  43. package/dist/runtime/layout/getZones.d.ts +8 -0
  44. package/dist/runtime/layout/getZones.js +32 -0
  45. package/dist/runtime/layout/index.d.ts +3 -3
  46. package/dist/runtime/layout/index.js +3 -3
  47. package/dist/runtime/{drag/DragActionHandler.d.ts → move/ActionHandler.d.ts} +19 -21
  48. package/dist/runtime/{drag/DragActionHandler.js → move/ActionHandler.js} +21 -18
  49. package/dist/runtime/{drag → move}/CloseAction.d.ts +9 -8
  50. package/dist/runtime/{drag → move}/CloseAction.js +31 -27
  51. package/dist/runtime/{drag → move}/FrameDragAction.d.ts +9 -8
  52. package/dist/runtime/{drag → move}/FrameDragAction.js +23 -22
  53. package/dist/runtime/{drag/DragDirectionStore.d.ts → move/MoveDirectionStore.d.ts} +4 -4
  54. package/dist/runtime/{drag/DragDirectionStore.js → move/MoveDirectionStore.js} +9 -9
  55. package/dist/runtime/{drag → move}/SplitAction.d.ts +10 -9
  56. package/dist/runtime/{drag → move}/SplitAction.js +53 -44
  57. package/dist/runtime/{drag → move}/createDefaultHandlers.d.ts +2 -2
  58. package/dist/runtime/types/index.d.ts +192 -171
  59. package/dist/runtime/types/index.js +2 -2
  60. package/dist/runtime/types/vue.d.ts +14 -16
  61. package/dist/runtime/types/vue.js +1 -1
  62. package/package.json +1 -1
  63. package/src/runtime/components/FrameDragHandle.vue +3 -3
  64. package/src/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
  65. package/src/runtime/components/LayoutDragEdgeHandle.vue +4 -4
  66. package/src/runtime/components/LayoutDragEdges.vue +5 -5
  67. package/src/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
  68. package/src/runtime/components/LayoutFrame.vue +2 -2
  69. package/src/runtime/components/LayoutIntersectionHandle.vue +4 -4
  70. package/src/runtime/components/LayoutIntersections.vue +4 -4
  71. package/src/runtime/components/LayoutWindow.vue +32 -32
  72. package/src/runtime/composables/useFrames.ts +115 -104
  73. package/src/runtime/demo/App.vue +18 -18
  74. package/src/runtime/demo/DemoControls.vue +5 -5
  75. package/src/runtime/helpers/createZoneSideClipPath.ts +2 -2
  76. package/src/runtime/helpers/{findFrameDraggableEdges.ts → findFrameMoveableEdges.ts} +4 -4
  77. package/src/runtime/helpers/{findDraggableEdge.ts → findMoveableEdge.ts} +1 -1
  78. package/src/runtime/helpers/index.ts +2 -2
  79. package/src/runtime/layout/createSplitDecoFromDrag.ts +2 -2
  80. package/src/runtime/layout/findSafeSplitEdge.ts +4 -4
  81. package/src/runtime/layout/getCloseFrameInfo.ts +4 -4
  82. package/src/runtime/layout/getFrameRearrangeInfo.ts +10 -10
  83. package/src/runtime/layout/getFrameSplitInfo.ts +5 -5
  84. package/src/runtime/layout/{getFrameDragZones.ts → getFrameZones.ts} +4 -4
  85. package/src/runtime/layout/{getWindowDragZones.ts → getWindowZones.ts} +1 -1
  86. package/src/runtime/layout/getZones.ts +48 -0
  87. package/src/runtime/layout/index.ts +3 -3
  88. package/src/runtime/{drag/DragActionHandler.ts → move/ActionHandler.ts} +48 -41
  89. package/src/runtime/{drag → move}/CloseAction.ts +42 -37
  90. package/src/runtime/{drag → move}/FrameDragAction.ts +37 -36
  91. package/src/runtime/{drag/DragDirectionStore.ts → move/MoveDirectionStore.ts} +10 -10
  92. package/src/runtime/{drag → move}/SplitAction.ts +64 -54
  93. package/src/runtime/{drag → move}/createDefaultHandlers.ts +2 -2
  94. package/src/runtime/types/index.ts +90 -69
  95. package/src/runtime/types/vue.ts +14 -14
  96. package/dist/runtime/layout/getDragZones.d.ts +0 -8
  97. package/dist/runtime/layout/getDragZones.js +0 -32
  98. package/src/runtime/layout/getDragZones.ts +0 -48
  99. /package/dist/runtime/{drag → move}/createDefaultHandlers.js +0 -0
@@ -1,10 +1,10 @@
1
- import { DragActionHandler } from "./DragActionHandler.js";
1
+ import { ActionHandler } from "./ActionHandler.js";
2
2
  import { createZoneSideClipPath } from "../helpers/createZoneSideClipPath.js";
3
3
  import { applyFrameChanges } from "../layout/applyFrameChanges.js";
4
- import { getDragZones } from "../layout/getDragZones.js";
5
4
  import { getFrameDockInfo } from "../layout/getFrameDockInfo.js";
6
5
  import { getFrameRearrangeInfo } from "../layout/getFrameRearrangeInfo.js";
7
6
  import { getFrameSwapInfo } from "../layout/getFrameSwapInfo.js";
7
+ import { getZones } from "../layout/getZones.js";
8
8
  import { settings } from "../settings.js";
9
9
  export class FrameDragAction {
10
10
  name = "frameDrag";
@@ -14,7 +14,7 @@ export class FrameDragAction {
14
14
  };
15
15
  debug = false;
16
16
  textHints = { actions: [], errors: [] };
17
- handleEvent = (_e, state) => state.isDragging === "frame";
17
+ handleEvent = (_e, state) => state.isMoving === "frame";
18
18
  dragHints = {
19
19
  actions: {
20
20
  split: "Drop to Split the current frame.",
@@ -60,7 +60,7 @@ export class FrameDragAction {
60
60
  }
61
61
  getDecos(matchedZone, state, result) {
62
62
  const isError = result instanceof Error;
63
- const frame = state.dragHoveredFrame;
63
+ const frame = state.moveHoveredFrame;
64
64
  if (!matchedZone || !frame) {
65
65
  const decos2 = [];
66
66
  this.modifyDecos(decos2);
@@ -93,53 +93,54 @@ export class FrameDragAction {
93
93
  this.reset();
94
94
  return false;
95
95
  }
96
- onDragChange(_type, _e, state) {
97
- if (state.dragDistance <= this.minDragDistance) {
98
- return { updateEdges: false, shapes: [], showDragging: false };
96
+ onMoveChange(type, _e, state) {
97
+ if (state.moveDistance <= this.minDragDistance) {
98
+ return { updateEdges: false, shapes: [], showMoving: false };
99
99
  }
100
- const { win, draggingFrameId, dragHoveredFrame } = state;
101
- const matchedZone = getDragZones(state, settings.zoneSizes);
100
+ const { win, movingFrameId, moveHoveredFrame } = state;
101
+ const matchedZone = getZones(state, settings.zoneSizes);
102
102
  if (!matchedZone) {
103
103
  this.state.lastReturn = void 0;
104
- } else if (dragHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
104
+ } else if (moveHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
105
105
  if (matchedZone.side !== "center") {
106
- this.state.lastReturn = getFrameRearrangeInfo(win, draggingFrameId, dragHoveredFrame.id, matchedZone.side);
106
+ this.state.lastReturn = getFrameRearrangeInfo(win, movingFrameId, moveHoveredFrame.id, matchedZone.side);
107
107
  } else {
108
- this.state.lastReturn = getFrameSwapInfo(win, draggingFrameId, dragHoveredFrame.id);
108
+ this.state.lastReturn = getFrameSwapInfo(win, movingFrameId, moveHoveredFrame.id);
109
109
  if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "swap";
110
110
  }
111
- } else if (matchedZone.type === "window" && dragHoveredFrame && !dragHoveredFrame.docked) {
112
- this.state.lastReturn = getFrameDockInfo(win, draggingFrameId, matchedZone.side);
111
+ } else if (matchedZone.type === "window" && moveHoveredFrame && !moveHoveredFrame.docked) {
112
+ this.state.lastReturn = getFrameDockInfo(win, movingFrameId, matchedZone.side);
113
113
  if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "dock";
114
114
  }
115
115
  this.setTextHints(this.state.lastReturn);
116
116
  const decos = this.getDecos(matchedZone, state, this.state.lastReturn);
117
117
  return {
118
- shapes: decos.flatMap((_) => _.shapes),
118
+ shapes: type === "end" ? [] : decos.flatMap((_) => _.shapes),
119
119
  updateEdges: false,
120
- showDragging: false
120
+ showMoving: false
121
121
  };
122
122
  }
123
- onDragApply(state) {
123
+ onMoveApply(state) {
124
124
  const result = this.state.lastReturn;
125
- if (!result || !state.dragHoveredFrame || !state.draggingFrameId) {
126
- this.reset();
125
+ if (!result || !state.moveHoveredFrame || !state.movingFrameId) {
127
126
  return true;
128
127
  }
129
128
  if (result instanceof Error) {
130
129
  this.hooks.onError?.(result);
131
130
  } else {
132
131
  if (this.debug) {
133
- DragActionHandler.debugState(this.name, "before", state, this.state, this.debug);
132
+ ActionHandler.debugState(this.name, "before", state, this.state, this.debug);
134
133
  }
135
134
  applyFrameChanges(state.win, result);
136
135
  if (this.debug) {
137
- DragActionHandler.debugState(this.name, "after", state, this.state, this.debug);
136
+ ActionHandler.debugState(this.name, "after", state, this.state, this.debug);
138
137
  }
139
138
  }
140
- this.reset();
141
139
  return true;
142
140
  }
141
+ onMoveEnded() {
142
+ this.reset();
143
+ }
143
144
  cancel() {
144
145
  this.reset();
145
146
  }
@@ -1,11 +1,11 @@
1
1
  import type { Direction, Orientation, Point } from "../types/index.js";
2
- export declare class DragDirectionStore {
2
+ export declare class MoveDirectionStore {
3
3
  hooks: {
4
4
  onUpdate: (directions: Record<Orientation, Direction | undefined>) => void;
5
5
  };
6
- constructor(hooks: DragDirectionStore["hooks"]);
6
+ constructor(hooks: MoveDirectionStore["hooks"]);
7
7
  lastPoint: Point | undefined;
8
- dragDirection: Record<Orientation, Direction | undefined>;
8
+ moveDirection: Record<Orientation, Direction | undefined>;
9
9
  lesser: {
10
10
  x: Direction;
11
11
  y: Direction;
@@ -16,5 +16,5 @@ export declare class DragDirectionStore {
16
16
  };
17
17
  reset(): void;
18
18
  update(point: Point): boolean;
19
- getDragDirection(coord: "x" | "y", point: Point): Direction | false;
19
+ getMoveDirection(coord: "x" | "y", point: Point): Direction | false;
20
20
  }
@@ -1,10 +1,10 @@
1
- export class DragDirectionStore {
1
+ export class MoveDirectionStore {
2
2
  hooks;
3
3
  constructor(hooks) {
4
4
  this.hooks = hooks;
5
5
  }
6
6
  lastPoint;
7
- dragDirection = {};
7
+ moveDirection = {};
8
8
  lesser = {
9
9
  x: "left",
10
10
  y: "up"
@@ -15,27 +15,27 @@ export class DragDirectionStore {
15
15
  };
16
16
  reset() {
17
17
  this.lastPoint = void 0;
18
- this.dragDirection = {};
18
+ this.moveDirection = {};
19
19
  }
20
20
  update(point) {
21
- const newXDirection = this.getDragDirection("x", point);
22
- const newYDirection = this.getDragDirection("y", point);
21
+ const newXDirection = this.getMoveDirection("x", point);
22
+ const newYDirection = this.getMoveDirection("y", point);
23
23
  let changed = false;
24
24
  if (newXDirection) {
25
- this.dragDirection.horizontal = newXDirection;
25
+ this.moveDirection.horizontal = newXDirection;
26
26
  }
27
27
  if (newYDirection) {
28
- this.dragDirection.vertical = newYDirection;
28
+ this.moveDirection.vertical = newYDirection;
29
29
  }
30
30
  if (this.lastPoint?.x !== point.x || this.lastPoint?.y !== point.y) {
31
31
  this.lastPoint = point;
32
32
  changed = true;
33
33
  }
34
34
  if (!changed) return false;
35
- this.hooks.onUpdate(this.dragDirection);
35
+ this.hooks.onUpdate(this.moveDirection);
36
36
  return true;
37
37
  }
38
- getDragDirection(coord, point) {
38
+ getMoveDirection(coord, point) {
39
39
  if (!this.lastPoint) return false;
40
40
  const diff = point[coord] - this.lastPoint[coord];
41
41
  if (diff > 0) return this.greater[coord];
@@ -1,9 +1,9 @@
1
1
  import { getFrameSplitInfo } from "../layout/getFrameSplitInfo.js";
2
- import type { ActionDragChangeResult, DragState, IDragAction, Point, SplitDeco } from "../types/index.js";
2
+ import type { ActionChangeResult, IAction, MoveState, Point, SplitDeco } from "../types/index.js";
3
3
  import type { KnownError } from "../utils/KnownError.js";
4
4
  export type SplitInfo = Exclude<ReturnType<typeof getFrameSplitInfo>, KnownError>;
5
5
  export type DragChangeType = "start" | "move" | "end";
6
- export declare class SplitAction implements IDragAction {
6
+ export declare class SplitAction implements IAction {
7
7
  name: "split";
8
8
  minDragDistance: number;
9
9
  state: {
@@ -15,7 +15,7 @@ export declare class SplitAction implements IDragAction {
15
15
  allowed: false;
16
16
  res: SplitInfo | undefined;
17
17
  lastPoint: Point | undefined;
18
- lastReturn: ActionDragChangeResult | undefined;
18
+ lastReturn: ActionChangeResult | undefined;
19
19
  };
20
20
  debug: boolean | string;
21
21
  textHints: {
@@ -26,7 +26,7 @@ export declare class SplitAction implements IDragAction {
26
26
  actions: string[] | ((type: DragChangeType) => string[]);
27
27
  transformError: (e: KnownError) => string;
28
28
  };
29
- handleEvent: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
29
+ handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean;
30
30
  modifyDecos: (shapes: SplitDeco[]) => void;
31
31
  hooks: {
32
32
  onStart?: () => void;
@@ -42,15 +42,16 @@ export declare class SplitAction implements IDragAction {
42
42
  minDragDistance?: number;
43
43
  });
44
44
  reset(): void;
45
- getDecos(state: DragState): SplitDeco[];
46
- canHandleRequest(e: PointerEvent | KeyboardEvent, state: DragState): boolean;
45
+ getDecos(state: MoveState): SplitDeco[];
46
+ canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean;
47
47
  setTextHints(result: true | SplitInfo | KnownError | undefined): void;
48
48
  getTextHints(type: "start" | "move" | "end"): {
49
49
  actions: string[];
50
50
  errors: string[];
51
51
  };
52
- calculateSplitRequest(state: DragState): boolean;
53
- onDragChange(_type: "start" | "end" | "move", _e: PointerEvent | undefined, state: DragState): ActionDragChangeResult;
54
- onDragApply(state: DragState): boolean;
52
+ calculateSplitRequest(state: MoveState): boolean;
53
+ onMoveChange(type: "start" | "end" | "move", _e: PointerEvent | undefined, state: MoveState): ActionChangeResult;
54
+ onMoveApply(state: MoveState): boolean;
55
+ onMoveEnded(): void;
55
56
  cancel(): void;
56
57
  }
@@ -1,4 +1,4 @@
1
- import { DragActionHandler } from "./DragActionHandler.js";
1
+ import { ActionHandler } from "./ActionHandler.js";
2
2
  import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
3
3
  import { oppositeSide } from "../helpers/oppositeSide.js";
4
4
  import { applyFrameChanges } from "../layout/applyFrameChanges.js";
@@ -15,7 +15,7 @@ export class SplitAction {
15
15
  actions: ["Hold Alt to Split"],
16
16
  transformError: (e) => e.message
17
17
  };
18
- handleEvent = (e, state) => e.altKey || state.isDraggingFromWindowEdge;
18
+ handleEvent = (e, state) => e.altKey || state.isMovingFromWindowEdge;
19
19
  modifyDecos = () => {
20
20
  };
21
21
  hooks;
@@ -42,19 +42,19 @@ export class SplitAction {
42
42
  let decos = [];
43
43
  const {
44
44
  win,
45
- isDragging,
46
- dragHoveredFrame,
47
- dragDirections,
48
- draggingEdges,
49
- dragPoint
45
+ isMoving,
46
+ moveHoveredFrame,
47
+ moveDirections,
48
+ movingEdges,
49
+ movePoint
50
50
  } = state;
51
- if (isDragging && this.state.allowed && dragHoveredFrame && draggingEdges.length === 1) {
52
- const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]));
51
+ if (isMoving && this.state.allowed && moveHoveredFrame && movingEdges.length === 1) {
52
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(movingEdges[0]));
53
53
  const deco = createSplitDecoFromDrag(
54
54
  win.frames,
55
- dragHoveredFrame,
56
- dragDirections[oppositeOrientation],
57
- dragPoint
55
+ moveHoveredFrame,
56
+ moveDirections[oppositeOrientation],
57
+ movePoint
58
58
  );
59
59
  decos = [deco];
60
60
  }
@@ -62,9 +62,9 @@ export class SplitAction {
62
62
  return decos;
63
63
  }
64
64
  canHandleRequest(e, state) {
65
- const { draggingEdges } = state;
66
- if (draggingEdges.length !== 1) return false;
67
- this.setTextHints(state.isDragging === "edge" && !state.isDraggingFromWindowEdge ? true : void 0);
65
+ const { movingEdges } = state;
66
+ if (movingEdges.length !== 1) return false;
67
+ this.setTextHints(state.isMoving === "edge" && !state.isMovingFromWindowEdge ? true : void 0);
68
68
  if (this.handleEvent(e, state)) {
69
69
  this.hooks.onStart?.();
70
70
  return true;
@@ -92,24 +92,24 @@ export class SplitAction {
92
92
  }
93
93
  calculateSplitRequest(state) {
94
94
  const {
95
- dragHoveredFrame,
96
- dragDirections,
97
- draggingEdges,
98
- dragPoint,
95
+ moveHoveredFrame,
96
+ moveDirections,
97
+ movingEdges,
98
+ movePoint,
99
99
  win
100
100
  } = state;
101
- const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]));
102
- const originalDragHoveredFrame = win.frames[dragHoveredFrame.id];
101
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(movingEdges[0]));
102
+ const originalDragHoveredFrame = win.frames[moveHoveredFrame.id];
103
103
  const canSplit = getFrameSplitInfo(
104
104
  originalDragHoveredFrame,
105
- dragDirections[oppositeOrientation],
106
- dragPoint
105
+ moveDirections[oppositeOrientation],
106
+ movePoint
107
107
  );
108
- this.setTextHints(state.isDragging === "edge" && !state.isDraggingFromWindowEdge ? canSplit : void 0);
108
+ this.setTextHints(state.isMoving === "edge" && !state.isMovingFromWindowEdge ? canSplit : void 0);
109
109
  if (!(canSplit instanceof Error)) {
110
110
  this.state.allowed = true;
111
111
  this.state.res = canSplit;
112
- this.state.lastPoint = dragPoint ? { ...dragPoint } : void 0;
112
+ this.state.lastPoint = movePoint ? { ...movePoint } : void 0;
113
113
  return true;
114
114
  } else {
115
115
  this.hooks.onError?.(canSplit);
@@ -118,56 +118,65 @@ export class SplitAction {
118
118
  return false;
119
119
  }
120
120
  }
121
- onDragChange(_type, _e, state) {
122
- const { dragHoveredFrame, dragDistance } = state;
123
- if (dragDistance <= this.minDragDistance) {
124
- return { updateEdges: false, shapes: [], showDragging: false };
121
+ onMoveChange(type, _e, state) {
122
+ const { moveHoveredFrame, moveDistance } = state;
123
+ if (moveDistance <= this.minDragDistance) {
124
+ return { updateEdges: false, shapes: [], showMoving: false };
125
125
  }
126
126
  let ok = false;
127
- if (dragHoveredFrame) {
128
- if (this.state.lastPoint?.x === state.dragPoint?.x && this.state.lastPoint?.y === state.dragPoint?.y && this.state.lastReturn) {
127
+ if (moveHoveredFrame) {
128
+ if (this.state.lastPoint?.x === state.movePoint?.x && this.state.lastPoint?.y === state.movePoint?.y && this.state.lastReturn) {
129
129
  return this.state.lastReturn;
130
130
  }
131
131
  ok = this.calculateSplitRequest(state);
132
132
  }
133
133
  const decos = this.getDecos(state);
134
134
  if (!ok) {
135
- if (dragHoveredFrame && dragHoveredFrame.docked) {
135
+ if (moveHoveredFrame && moveHoveredFrame.docked) {
136
136
  const errorDeco = {
137
137
  type: "rect",
138
138
  data: {
139
- x: dragHoveredFrame.x,
140
- y: dragHoveredFrame.y,
141
- width: dragHoveredFrame.width,
142
- height: dragHoveredFrame.height
139
+ x: moveHoveredFrame.x,
140
+ y: moveHoveredFrame.y,
141
+ width: moveHoveredFrame.width,
142
+ height: moveHoveredFrame.height
143
143
  },
144
144
  attrs: { class: "deco-split-error bg-red-500/50" }
145
145
  };
146
- this.state.lastReturn = { updateEdges: true, shapes: [errorDeco], showDragging: false };
146
+ this.state.lastReturn = {
147
+ updateEdges: true,
148
+ shapes: type === "end" ? [] : [errorDeco],
149
+ showMoving: false
150
+ };
147
151
  return this.state.lastReturn;
148
152
  }
149
153
  }
150
- this.state.lastReturn = { updateEdges: false, shapes: decos.flatMap((_) => _.shapes), showDragging: false };
154
+ this.state.lastReturn = {
155
+ updateEdges: false,
156
+ shapes: type === "end" ? [] : decos.flatMap((_) => _.shapes),
157
+ showMoving: false
158
+ };
151
159
  return this.state.lastReturn;
152
160
  }
153
- onDragApply(state) {
154
- if (this.state.res && state.dragHoveredFrame) {
161
+ onMoveApply(state) {
162
+ if (this.state.res && state.moveHoveredFrame) {
155
163
  const ok = this.calculateSplitRequest(state);
156
164
  if (ok) {
157
165
  if (this.debug) {
158
- DragActionHandler.debugState(this.name, "before", state, this.state, this.debug);
166
+ ActionHandler.debugState(this.name, "before", state, this.state, this.debug);
159
167
  }
160
168
  applyFrameChanges(state.win, this.state.res);
161
169
  if (this.debug) {
162
- DragActionHandler.debugState(this.name, "after", state, this.state, this.debug);
170
+ ActionHandler.debugState(this.name, "after", state, this.state, this.debug);
163
171
  }
164
172
  }
165
173
  }
166
- this.reset();
167
174
  return true;
168
175
  }
169
- cancel() {
176
+ onMoveEnded() {
170
177
  this.reset();
178
+ }
179
+ cancel() {
171
180
  this.hooks.onCancel?.();
172
181
  }
173
182
  }
@@ -1,4 +1,4 @@
1
- import type { IDragAction } from "../types/index.js";
1
+ import type { IAction } from "../types/index.js";
2
2
  /**
3
3
  * Creates the default drag actions (Split, Close, FrameDrag).
4
4
  */
@@ -6,4 +6,4 @@ export declare function createDefaultHandlers(config?: {
6
6
  debugSplit?: boolean;
7
7
  debugClose?: boolean;
8
8
  debugFrameDrag?: boolean;
9
- }): IDragAction[];
9
+ }): IAction[];