@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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/FrameDragHandle.vue +3 -3
- package/dist/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
- package/dist/runtime/components/LayoutDragEdgeHandle.d.vue.ts +2 -2
- package/dist/runtime/components/LayoutDragEdgeHandle.vue +2 -2
- package/dist/runtime/components/LayoutDragEdgeHandle.vue.d.ts +2 -2
- package/dist/runtime/components/LayoutDragEdges.vue +5 -5
- package/dist/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
- package/dist/runtime/components/LayoutFrame.vue +2 -2
- package/dist/runtime/components/LayoutIntersectionHandle.d.vue.ts +2 -2
- package/dist/runtime/components/LayoutIntersectionHandle.vue +2 -2
- package/dist/runtime/components/LayoutIntersectionHandle.vue.d.ts +2 -2
- package/dist/runtime/components/LayoutIntersections.vue +4 -4
- package/dist/runtime/components/LayoutWindow.d.vue.ts +44 -44
- package/dist/runtime/components/LayoutWindow.vue +27 -27
- package/dist/runtime/components/LayoutWindow.vue.d.ts +44 -44
- package/dist/runtime/composables/useFrames.d.ts +107 -109
- package/dist/runtime/composables/useFrames.js +107 -99
- package/dist/runtime/demo/App.vue +16 -16
- package/dist/runtime/demo/DemoControls.d.vue.ts +2 -2
- package/dist/runtime/demo/DemoControls.vue +4 -4
- package/dist/runtime/demo/DemoControls.vue.d.ts +2 -2
- package/dist/runtime/helpers/createZoneSideClipPath.d.ts +2 -2
- package/dist/runtime/helpers/{findFrameDraggableEdges.d.ts → findFrameMoveableEdges.d.ts} +2 -2
- package/dist/runtime/helpers/{findFrameDraggableEdges.js → findFrameMoveableEdges.js} +3 -3
- package/dist/runtime/helpers/{findDraggableEdge.d.ts → findMoveableEdge.d.ts} +1 -1
- package/dist/runtime/helpers/{findDraggableEdge.js → findMoveableEdge.js} +1 -1
- package/dist/runtime/helpers/index.d.ts +2 -2
- package/dist/runtime/helpers/index.js +2 -2
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +1 -1
- package/dist/runtime/layout/createSplitDecoFromDrag.js +2 -2
- package/dist/runtime/layout/findSafeSplitEdge.d.ts +1 -1
- package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
- package/dist/runtime/layout/getCloseFrameInfo.js +4 -4
- package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +2 -2
- package/dist/runtime/layout/getFrameRearrangeInfo.js +8 -8
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +1 -1
- package/dist/runtime/layout/getFrameSplitInfo.js +2 -2
- package/dist/runtime/layout/{getFrameDragZones.d.ts → getFrameZones.d.ts} +3 -3
- package/dist/runtime/layout/{getFrameDragZones.js → getFrameZones.js} +1 -1
- package/dist/runtime/layout/{getWindowDragZones.d.ts → getWindowZones.d.ts} +1 -1
- package/dist/runtime/layout/{getWindowDragZones.js → getWindowZones.js} +1 -1
- package/dist/runtime/layout/getZones.d.ts +8 -0
- package/dist/runtime/layout/getZones.js +32 -0
- package/dist/runtime/layout/index.d.ts +3 -3
- package/dist/runtime/layout/index.js +3 -3
- package/dist/runtime/{drag/DragActionHandler.d.ts → move/ActionHandler.d.ts} +19 -21
- package/dist/runtime/{drag/DragActionHandler.js → move/ActionHandler.js} +21 -18
- package/dist/runtime/{drag → move}/CloseAction.d.ts +9 -8
- package/dist/runtime/{drag → move}/CloseAction.js +31 -27
- package/dist/runtime/{drag → move}/FrameDragAction.d.ts +9 -8
- package/dist/runtime/{drag → move}/FrameDragAction.js +23 -22
- package/dist/runtime/{drag/DragDirectionStore.d.ts → move/MoveDirectionStore.d.ts} +4 -4
- package/dist/runtime/{drag/DragDirectionStore.js → move/MoveDirectionStore.js} +9 -9
- package/dist/runtime/{drag → move}/SplitAction.d.ts +10 -9
- package/dist/runtime/{drag → move}/SplitAction.js +53 -44
- package/dist/runtime/{drag → move}/createDefaultHandlers.d.ts +2 -2
- package/dist/runtime/types/index.d.ts +192 -171
- package/dist/runtime/types/index.js +2 -2
- package/dist/runtime/types/vue.d.ts +14 -16
- package/dist/runtime/types/vue.js +1 -1
- package/package.json +1 -1
- package/src/runtime/components/FrameDragHandle.vue +3 -3
- package/src/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
- package/src/runtime/components/LayoutDragEdgeHandle.vue +4 -4
- package/src/runtime/components/LayoutDragEdges.vue +5 -5
- package/src/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
- package/src/runtime/components/LayoutFrame.vue +2 -2
- package/src/runtime/components/LayoutIntersectionHandle.vue +4 -4
- package/src/runtime/components/LayoutIntersections.vue +4 -4
- package/src/runtime/components/LayoutWindow.vue +32 -32
- package/src/runtime/composables/useFrames.ts +115 -104
- package/src/runtime/demo/App.vue +18 -18
- package/src/runtime/demo/DemoControls.vue +5 -5
- package/src/runtime/helpers/createZoneSideClipPath.ts +2 -2
- package/src/runtime/helpers/{findFrameDraggableEdges.ts → findFrameMoveableEdges.ts} +4 -4
- package/src/runtime/helpers/{findDraggableEdge.ts → findMoveableEdge.ts} +1 -1
- package/src/runtime/helpers/index.ts +2 -2
- package/src/runtime/layout/createSplitDecoFromDrag.ts +2 -2
- package/src/runtime/layout/findSafeSplitEdge.ts +4 -4
- package/src/runtime/layout/getCloseFrameInfo.ts +4 -4
- package/src/runtime/layout/getFrameRearrangeInfo.ts +10 -10
- package/src/runtime/layout/getFrameSplitInfo.ts +5 -5
- package/src/runtime/layout/{getFrameDragZones.ts → getFrameZones.ts} +4 -4
- package/src/runtime/layout/{getWindowDragZones.ts → getWindowZones.ts} +1 -1
- package/src/runtime/layout/getZones.ts +48 -0
- package/src/runtime/layout/index.ts +3 -3
- package/src/runtime/{drag/DragActionHandler.ts → move/ActionHandler.ts} +48 -41
- package/src/runtime/{drag → move}/CloseAction.ts +42 -37
- package/src/runtime/{drag → move}/FrameDragAction.ts +37 -36
- package/src/runtime/{drag/DragDirectionStore.ts → move/MoveDirectionStore.ts} +10 -10
- package/src/runtime/{drag → move}/SplitAction.ts +64 -54
- package/src/runtime/{drag → move}/createDefaultHandlers.ts +2 -2
- package/src/runtime/types/index.ts +90 -69
- package/src/runtime/types/vue.ts +14 -14
- package/dist/runtime/layout/getDragZones.d.ts +0 -8
- package/dist/runtime/layout/getDragZones.js +0 -32
- package/src/runtime/layout/getDragZones.ts +0 -48
- /package/dist/runtime/{drag → move}/createDefaultHandlers.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
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.
|
|
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
|
-
|
|
97
|
-
if (state.
|
|
98
|
-
return { updateEdges: false, shapes: [],
|
|
96
|
+
onMoveChange(type, _e, state) {
|
|
97
|
+
if (state.moveDistance <= this.minDragDistance) {
|
|
98
|
+
return { updateEdges: false, shapes: [], showMoving: false };
|
|
99
99
|
}
|
|
100
|
-
const { win,
|
|
101
|
-
const matchedZone =
|
|
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 (
|
|
104
|
+
} else if (moveHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
|
|
105
105
|
if (matchedZone.side !== "center") {
|
|
106
|
-
this.state.lastReturn = getFrameRearrangeInfo(win,
|
|
106
|
+
this.state.lastReturn = getFrameRearrangeInfo(win, movingFrameId, moveHoveredFrame.id, matchedZone.side);
|
|
107
107
|
} else {
|
|
108
|
-
this.state.lastReturn = getFrameSwapInfo(win,
|
|
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" &&
|
|
112
|
-
this.state.lastReturn = getFrameDockInfo(win,
|
|
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
|
-
|
|
120
|
+
showMoving: false
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
onMoveApply(state) {
|
|
124
124
|
const result = this.state.lastReturn;
|
|
125
|
-
if (!result || !state.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
2
|
+
export declare class MoveDirectionStore {
|
|
3
3
|
hooks: {
|
|
4
4
|
onUpdate: (directions: Record<Orientation, Direction | undefined>) => void;
|
|
5
5
|
};
|
|
6
|
-
constructor(hooks:
|
|
6
|
+
constructor(hooks: MoveDirectionStore["hooks"]);
|
|
7
7
|
lastPoint: Point | undefined;
|
|
8
|
-
|
|
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
|
-
|
|
19
|
+
getMoveDirection(coord: "x" | "y", point: Point): Direction | false;
|
|
20
20
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class MoveDirectionStore {
|
|
2
2
|
hooks;
|
|
3
3
|
constructor(hooks) {
|
|
4
4
|
this.hooks = hooks;
|
|
5
5
|
}
|
|
6
6
|
lastPoint;
|
|
7
|
-
|
|
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.
|
|
18
|
+
this.moveDirection = {};
|
|
19
19
|
}
|
|
20
20
|
update(point) {
|
|
21
|
-
const newXDirection = this.
|
|
22
|
-
const newYDirection = this.
|
|
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.
|
|
25
|
+
this.moveDirection.horizontal = newXDirection;
|
|
26
26
|
}
|
|
27
27
|
if (newYDirection) {
|
|
28
|
-
this.
|
|
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.
|
|
35
|
+
this.hooks.onUpdate(this.moveDirection);
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
|
-
|
|
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 {
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
46
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state:
|
|
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:
|
|
53
|
-
|
|
54
|
-
|
|
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 {
|
|
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.
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
isMoving,
|
|
46
|
+
moveHoveredFrame,
|
|
47
|
+
moveDirections,
|
|
48
|
+
movingEdges,
|
|
49
|
+
movePoint
|
|
50
50
|
} = state;
|
|
51
|
-
if (
|
|
52
|
-
const oppositeOrientation = oppositeSide(getEdgeOrientation(
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 {
|
|
66
|
-
if (
|
|
67
|
-
this.setTextHints(state.
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
moveHoveredFrame,
|
|
96
|
+
moveDirections,
|
|
97
|
+
movingEdges,
|
|
98
|
+
movePoint,
|
|
99
99
|
win
|
|
100
100
|
} = state;
|
|
101
|
-
const oppositeOrientation = oppositeSide(getEdgeOrientation(
|
|
102
|
-
const originalDragHoveredFrame = win.frames[
|
|
101
|
+
const oppositeOrientation = oppositeSide(getEdgeOrientation(movingEdges[0]));
|
|
102
|
+
const originalDragHoveredFrame = win.frames[moveHoveredFrame.id];
|
|
103
103
|
const canSplit = getFrameSplitInfo(
|
|
104
104
|
originalDragHoveredFrame,
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
moveDirections[oppositeOrientation],
|
|
106
|
+
movePoint
|
|
107
107
|
);
|
|
108
|
-
this.setTextHints(state.
|
|
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 =
|
|
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
|
-
|
|
122
|
-
const {
|
|
123
|
-
if (
|
|
124
|
-
return { updateEdges: false, shapes: [],
|
|
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 (
|
|
128
|
-
if (this.state.lastPoint?.x === state.
|
|
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 (
|
|
135
|
+
if (moveHoveredFrame && moveHoveredFrame.docked) {
|
|
136
136
|
const errorDeco = {
|
|
137
137
|
type: "rect",
|
|
138
138
|
data: {
|
|
139
|
-
x:
|
|
140
|
-
y:
|
|
141
|
-
width:
|
|
142
|
-
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 = {
|
|
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 = {
|
|
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
|
-
|
|
154
|
-
if (this.state.res && state.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
}):
|
|
9
|
+
}): IAction[];
|