@witchcraft/layout 0.4.3 → 0.5.0
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 +54 -45
- package/dist/runtime/components/LayoutWindow.vue +29 -29
- package/dist/runtime/components/LayoutWindow.vue.d.ts +54 -45
- package/dist/runtime/composables/useFrames.d.ts +142 -129
- package/dist/runtime/composables/useFrames.js +122 -94
- 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/demo/tailwind.css +1 -1
- package/dist/runtime/helpers/createZoneSideClipPath.d.ts +2 -2
- package/dist/runtime/helpers/findEdgesTouchingWindow.d.ts +7 -0
- package/dist/runtime/helpers/findEdgesTouchingWindow.js +20 -0
- 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 +10 -3
- package/dist/runtime/helpers/index.js +10 -3
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +1 -1
- package/dist/runtime/layout/createSplitDecoFromDrag.js +2 -2
- package/dist/runtime/layout/debugFrame.js +5 -1
- 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/getFrameCollapseInfo.d.ts +1 -1
- package/dist/runtime/layout/getFrameCollapseInfo.js +9 -29
- package/dist/runtime/layout/getFrameDockInfo.d.ts +1 -1
- package/dist/runtime/layout/getFrameDockInfo.js +61 -44
- package/dist/runtime/layout/getFrameExpandInfo.d.ts +11 -0
- package/dist/runtime/layout/getFrameExpandInfo.js +49 -0
- package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +2 -2
- package/dist/runtime/layout/getFrameRearrangeInfo.js +8 -8
- package/dist/runtime/layout/getFrameShrinkInfo.d.ts +14 -0
- package/dist/runtime/layout/getFrameShrinkInfo.js +48 -0
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +1 -1
- package/dist/runtime/layout/getFrameSplitInfo.js +2 -2
- package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +1 -1
- package/dist/runtime/layout/getFrameUncollapseInfo.js +6 -20
- 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/getUpdateWindowSizeInfo.js +10 -12
- 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 +6 -3
- package/dist/runtime/layout/index.js +6 -3
- package/dist/runtime/{drag/DragActionHandler.d.ts → move/ActionHandler.d.ts} +18 -18
- package/dist/runtime/{drag/DragActionHandler.js → move/ActionHandler.js} +19 -19
- package/dist/runtime/{drag → move}/CloseAction.d.ts +8 -8
- package/dist/runtime/{drag → move}/CloseAction.js +29 -26
- package/dist/runtime/{drag → move}/FrameDragAction.d.ts +8 -8
- package/dist/runtime/{drag → move}/FrameDragAction.js +23 -21
- 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 +9 -9
- package/dist/runtime/{drag → move}/SplitAction.js +46 -43
- package/dist/runtime/{drag → move}/createDefaultHandlers.d.ts +2 -2
- package/dist/runtime/types/index.d.ts +242 -158
- package/dist/runtime/types/index.js +4 -3
- package/dist/runtime/types/vue.d.ts +25 -18
- package/dist/runtime/types/vue.js +1 -1
- package/package.json +3 -2
- 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 +35 -35
- package/src/runtime/composables/useFrames.ts +141 -121
- package/src/runtime/demo/App.vue +18 -18
- package/src/runtime/demo/DemoControls.vue +5 -5
- package/src/runtime/demo/tailwind.css +4 -0
- package/src/runtime/helpers/createZoneSideClipPath.ts +2 -2
- package/src/runtime/helpers/findEdgesTouchingWindow.ts +30 -0
- 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 +10 -3
- package/src/runtime/layout/createSplitDecoFromDrag.ts +2 -2
- package/src/runtime/layout/debugFrame.ts +6 -1
- package/src/runtime/layout/findSafeSplitEdge.ts +4 -4
- package/src/runtime/layout/getCloseFrameInfo.ts +4 -4
- package/src/runtime/layout/getFrameCollapseInfo.ts +12 -41
- package/src/runtime/layout/getFrameDockInfo.ts +77 -57
- package/src/runtime/layout/getFrameExpandInfo.ts +84 -0
- package/src/runtime/layout/getFrameRearrangeInfo.ts +10 -10
- package/src/runtime/layout/getFrameShrinkInfo.ts +87 -0
- package/src/runtime/layout/getFrameSplitInfo.ts +5 -5
- package/src/runtime/layout/getFrameUncollapseInfo.ts +8 -30
- package/src/runtime/layout/{getFrameDragZones.ts → getFrameZones.ts} +4 -4
- package/src/runtime/layout/getUpdateWindowSizeInfo.ts +16 -22
- package/src/runtime/layout/{getWindowDragZones.ts → getWindowZones.ts} +1 -1
- package/src/runtime/layout/getZones.ts +48 -0
- package/src/runtime/layout/index.ts +6 -3
- package/src/runtime/{drag/DragActionHandler.ts → move/ActionHandler.ts} +44 -42
- package/src/runtime/{drag → move}/CloseAction.ts +39 -36
- package/src/runtime/{drag → move}/FrameDragAction.ts +36 -35
- package/src/runtime/{drag/DragDirectionStore.ts → move/MoveDirectionStore.ts} +10 -10
- package/src/runtime/{drag → move}/SplitAction.ts +56 -53
- package/src/runtime/{drag/defaultDragActions.ts → move/createDefaultHandlers.ts} +2 -2
- package/src/runtime/types/index.ts +104 -55
- package/src/runtime/types/vue.ts +18 -16
- package/dist/runtime/drag/defaultDragActions.d.ts +0 -9
- package/dist/runtime/drag/defaultDragActions.js +0 -10
- package/dist/runtime/layout/getDragZones.d.ts +0 -8
- package/dist/runtime/layout/getDragZones.js +0 -32
- package/src/runtime/drag/createDefaultHandlers.ts +0 -20
- 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,23 +93,27 @@ export class FrameDragAction {
|
|
|
93
93
|
this.reset();
|
|
94
94
|
return false;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
96
|
+
onMoveChange(type, _e, state) {
|
|
97
|
+
if (type === "end") {
|
|
98
|
+
this.reset();
|
|
99
|
+
return { shapes: [] };
|
|
100
|
+
}
|
|
101
|
+
if (state.moveDistance <= this.minDragDistance) {
|
|
102
|
+
return { updateEdges: false, shapes: [], showMoving: false };
|
|
99
103
|
}
|
|
100
|
-
const { win,
|
|
101
|
-
const matchedZone =
|
|
104
|
+
const { win, movingFrameId, moveHoveredFrame } = state;
|
|
105
|
+
const matchedZone = getZones(state, settings.zoneSizes);
|
|
102
106
|
if (!matchedZone) {
|
|
103
107
|
this.state.lastReturn = void 0;
|
|
104
|
-
} else if (
|
|
108
|
+
} else if (moveHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
|
|
105
109
|
if (matchedZone.side !== "center") {
|
|
106
|
-
this.state.lastReturn = getFrameRearrangeInfo(win,
|
|
110
|
+
this.state.lastReturn = getFrameRearrangeInfo(win, movingFrameId, moveHoveredFrame.id, matchedZone.side);
|
|
107
111
|
} else {
|
|
108
|
-
this.state.lastReturn = getFrameSwapInfo(win,
|
|
112
|
+
this.state.lastReturn = getFrameSwapInfo(win, movingFrameId, moveHoveredFrame.id);
|
|
109
113
|
if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "swap";
|
|
110
114
|
}
|
|
111
|
-
} else if (matchedZone.type === "window" &&
|
|
112
|
-
this.state.lastReturn = getFrameDockInfo(win,
|
|
115
|
+
} else if (matchedZone.type === "window" && moveHoveredFrame && !moveHoveredFrame.docked) {
|
|
116
|
+
this.state.lastReturn = getFrameDockInfo(win, movingFrameId, matchedZone.side);
|
|
113
117
|
if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "dock";
|
|
114
118
|
}
|
|
115
119
|
this.setTextHints(this.state.lastReturn);
|
|
@@ -117,27 +121,25 @@ export class FrameDragAction {
|
|
|
117
121
|
return {
|
|
118
122
|
shapes: decos.flatMap((_) => _.shapes),
|
|
119
123
|
updateEdges: false,
|
|
120
|
-
|
|
124
|
+
showMoving: false
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
|
-
|
|
127
|
+
onMoveApply(state) {
|
|
124
128
|
const result = this.state.lastReturn;
|
|
125
|
-
if (!result || !state.
|
|
126
|
-
this.reset();
|
|
129
|
+
if (!result || !state.moveHoveredFrame || !state.movingFrameId) {
|
|
127
130
|
return true;
|
|
128
131
|
}
|
|
129
132
|
if (result instanceof Error) {
|
|
130
133
|
this.hooks.onError?.(result);
|
|
131
134
|
} else {
|
|
132
135
|
if (this.debug) {
|
|
133
|
-
|
|
136
|
+
ActionHandler.debugState(this.name, "before", state, this.state, this.debug);
|
|
134
137
|
}
|
|
135
138
|
applyFrameChanges(state.win, result);
|
|
136
139
|
if (this.debug) {
|
|
137
|
-
|
|
140
|
+
ActionHandler.debugState(this.name, "after", state, this.state, this.debug);
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
|
-
this.reset();
|
|
141
143
|
return true;
|
|
142
144
|
}
|
|
143
145
|
cancel() {
|
|
@@ -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,15 @@ 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
55
|
cancel(): void;
|
|
56
56
|
}
|
|
@@ -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,52 +118,55 @@ export class SplitAction {
|
|
|
118
118
|
return false;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return {
|
|
121
|
+
onMoveChange(type, _e, state) {
|
|
122
|
+
if (type === "end") {
|
|
123
|
+
this.reset();
|
|
124
|
+
return { shapes: [] };
|
|
125
|
+
}
|
|
126
|
+
const { moveHoveredFrame, moveDistance } = state;
|
|
127
|
+
if (moveDistance <= this.minDragDistance) {
|
|
128
|
+
return { updateEdges: false, shapes: [], showMoving: false };
|
|
125
129
|
}
|
|
126
130
|
let ok = false;
|
|
127
|
-
if (
|
|
128
|
-
if (this.state.lastPoint?.x === state.
|
|
131
|
+
if (moveHoveredFrame) {
|
|
132
|
+
if (this.state.lastPoint?.x === state.movePoint?.x && this.state.lastPoint?.y === state.movePoint?.y && this.state.lastReturn) {
|
|
129
133
|
return this.state.lastReturn;
|
|
130
134
|
}
|
|
131
135
|
ok = this.calculateSplitRequest(state);
|
|
132
136
|
}
|
|
133
137
|
const decos = this.getDecos(state);
|
|
134
138
|
if (!ok) {
|
|
135
|
-
if (
|
|
139
|
+
if (moveHoveredFrame && moveHoveredFrame.docked) {
|
|
136
140
|
const errorDeco = {
|
|
137
141
|
type: "rect",
|
|
138
142
|
data: {
|
|
139
|
-
x:
|
|
140
|
-
y:
|
|
141
|
-
width:
|
|
142
|
-
height:
|
|
143
|
+
x: moveHoveredFrame.x,
|
|
144
|
+
y: moveHoveredFrame.y,
|
|
145
|
+
width: moveHoveredFrame.width,
|
|
146
|
+
height: moveHoveredFrame.height
|
|
143
147
|
},
|
|
144
148
|
attrs: { class: "deco-split-error bg-red-500/50" }
|
|
145
149
|
};
|
|
146
|
-
this.state.lastReturn = { updateEdges: true, shapes: [errorDeco],
|
|
150
|
+
this.state.lastReturn = { updateEdges: true, shapes: [errorDeco], showMoving: false };
|
|
147
151
|
return this.state.lastReturn;
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
|
-
this.state.lastReturn = { updateEdges: false, shapes: decos.flatMap((_) => _.shapes),
|
|
154
|
+
this.state.lastReturn = { updateEdges: false, shapes: decos.flatMap((_) => _.shapes), showMoving: false };
|
|
151
155
|
return this.state.lastReturn;
|
|
152
156
|
}
|
|
153
|
-
|
|
154
|
-
if (this.state.res && state.
|
|
157
|
+
onMoveApply(state) {
|
|
158
|
+
if (this.state.res && state.moveHoveredFrame) {
|
|
155
159
|
const ok = this.calculateSplitRequest(state);
|
|
156
160
|
if (ok) {
|
|
157
161
|
if (this.debug) {
|
|
158
|
-
|
|
162
|
+
ActionHandler.debugState(this.name, "before", state, this.state, this.debug);
|
|
159
163
|
}
|
|
160
164
|
applyFrameChanges(state.win, this.state.res);
|
|
161
165
|
if (this.debug) {
|
|
162
|
-
|
|
166
|
+
ActionHandler.debugState(this.name, "after", state, this.state, this.debug);
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
|
-
this.reset();
|
|
167
170
|
return true;
|
|
168
171
|
}
|
|
169
172
|
cancel() {
|
|
@@ -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[];
|