@witchcraft/layout 0.0.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/README.md +474 -0
- package/dist/module.d.mts +14 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +26 -0
- package/dist/runtime/components/LayoutDecos.d.vue.ts +0 -0
- package/dist/runtime/components/LayoutDecos.vue +54 -0
- package/dist/runtime/components/LayoutDecos.vue.d.ts +0 -0
- package/dist/runtime/components/LayoutEdges.d.vue.ts +0 -0
- package/dist/runtime/components/LayoutEdges.vue +145 -0
- package/dist/runtime/components/LayoutEdges.vue.d.ts +0 -0
- package/dist/runtime/components/LayoutFrame.d.vue.ts +0 -0
- package/dist/runtime/components/LayoutFrame.vue +41 -0
- package/dist/runtime/components/LayoutFrame.vue.d.ts +0 -0
- package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +0 -0
- package/dist/runtime/components/LayoutShapeSquare.vue +36 -0
- package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +0 -0
- package/dist/runtime/components/LayoutWindow.d.vue.ts +0 -0
- package/dist/runtime/components/LayoutWindow.vue +183 -0
- package/dist/runtime/components/LayoutWindow.vue.d.ts +0 -0
- package/dist/runtime/composables/useFrames.d.ts +0 -0
- package/dist/runtime/composables/useFrames.js +184 -0
- package/dist/runtime/demo/App.d.vue.ts +0 -0
- package/dist/runtime/demo/App.vue +121 -0
- package/dist/runtime/demo/App.vue.d.ts +0 -0
- package/dist/runtime/demo/DemoControls.d.vue.ts +0 -0
- package/dist/runtime/demo/DemoControls.vue +14 -0
- package/dist/runtime/demo/DemoControls.vue.d.ts +0 -0
- package/dist/runtime/demo/README.md +1 -0
- package/dist/runtime/demo/main.d.ts +0 -0
- package/dist/runtime/demo/main.js +4 -0
- package/dist/runtime/demo/sharedLayoutInstance.d.ts +0 -0
- package/dist/runtime/demo/sharedLayoutInstance.js +5 -0
- package/dist/runtime/demo/tailwind.css +1 -0
- package/dist/runtime/drag/CloseAction.d.ts +0 -0
- package/dist/runtime/drag/CloseAction.js +121 -0
- package/dist/runtime/drag/DragActionHandler.d.ts +0 -0
- package/dist/runtime/drag/DragActionHandler.js +83 -0
- package/dist/runtime/drag/DragDirectionStore.d.ts +0 -0
- package/dist/runtime/drag/DragDirectionStore.js +45 -0
- package/dist/runtime/drag/SplitAction.d.ts +0 -0
- package/dist/runtime/drag/SplitAction.js +110 -0
- package/dist/runtime/drag/types.d.ts +0 -0
- package/dist/runtime/drag/types.js +0 -0
- package/dist/runtime/helpers/addPointsToIntersection.d.ts +0 -0
- package/dist/runtime/helpers/addPointsToIntersection.js +7 -0
- package/dist/runtime/helpers/assertEdgeSorted.d.ts +0 -0
- package/dist/runtime/helpers/assertEdgeSorted.js +7 -0
- package/dist/runtime/helpers/assertItemIn.d.ts +0 -0
- package/dist/runtime/helpers/assertItemIn.js +8 -0
- package/dist/runtime/helpers/assertItemNotIn.d.ts +0 -0
- package/dist/runtime/helpers/assertItemNotIn.js +7 -0
- package/dist/runtime/helpers/assertLayoutHasActiveWindow.d.ts +0 -0
- package/dist/runtime/helpers/assertLayoutHasActiveWindow.js +7 -0
- package/dist/runtime/helpers/assertValidWinAndFrame.d.ts +0 -0
- package/dist/runtime/helpers/assertValidWinAndFrame.js +5 -0
- package/dist/runtime/helpers/assertValidWinAndFrameIds.d.ts +0 -0
- package/dist/runtime/helpers/assertValidWinAndFrameIds.js +6 -0
- package/dist/runtime/helpers/assertWindowHasActiveFrame.d.ts +0 -0
- package/dist/runtime/helpers/assertWindowHasActiveFrame.js +7 -0
- package/dist/runtime/helpers/clampNumber.d.ts +0 -0
- package/dist/runtime/helpers/clampNumber.js +3 -0
- package/dist/runtime/helpers/cloneFrame.d.ts +0 -0
- package/dist/runtime/helpers/cloneFrame.js +3 -0
- package/dist/runtime/helpers/cloneFrames.d.ts +0 -0
- package/dist/runtime/helpers/cloneFrames.js +16 -0
- package/dist/runtime/helpers/containsEdge.d.ts +0 -0
- package/dist/runtime/helpers/containsEdge.js +13 -0
- package/dist/runtime/helpers/convertLayoutWindowToWorkspace.d.ts +0 -0
- package/dist/runtime/helpers/convertLayoutWindowToWorkspace.js +10 -0
- package/dist/runtime/helpers/copySize.d.ts +0 -0
- package/dist/runtime/helpers/copySize.js +5 -0
- package/dist/runtime/helpers/createEdge.d.ts +0 -0
- package/dist/runtime/helpers/createEdge.js +13 -0
- package/dist/runtime/helpers/dirToOrientation.d.ts +0 -0
- package/dist/runtime/helpers/dirToOrientation.js +10 -0
- package/dist/runtime/helpers/dirToSide.d.ts +0 -0
- package/dist/runtime/helpers/dirToSide.js +5 -0
- package/dist/runtime/helpers/doEdgesOverlap.d.ts +0 -0
- package/dist/runtime/helpers/doEdgesOverlap.js +22 -0
- package/dist/runtime/helpers/doesEdgeContinueEdge.d.ts +0 -0
- package/dist/runtime/helpers/doesEdgeContinueEdge.js +17 -0
- package/dist/runtime/helpers/edgeToPoints.d.ts +0 -0
- package/dist/runtime/helpers/edgeToPoints.js +3 -0
- package/dist/runtime/helpers/findDraggableEdge.d.ts +0 -0
- package/dist/runtime/helpers/findDraggableEdge.js +13 -0
- package/dist/runtime/helpers/findFrameDraggableEdges.d.ts +0 -0
- package/dist/runtime/helpers/findFrameDraggableEdges.js +18 -0
- package/dist/runtime/helpers/frameToEdges.d.ts +0 -0
- package/dist/runtime/helpers/frameToEdges.js +21 -0
- package/dist/runtime/helpers/frameToPoints.d.ts +0 -0
- package/dist/runtime/helpers/frameToPoints.js +7 -0
- package/dist/runtime/helpers/getEdgeOrientation.d.ts +0 -0
- package/dist/runtime/helpers/getEdgeOrientation.js +4 -0
- package/dist/runtime/helpers/getEdgeSharedDirection.d.ts +0 -0
- package/dist/runtime/helpers/getEdgeSharedDirection.js +7 -0
- package/dist/runtime/helpers/getEdgeSide.d.ts +0 -0
- package/dist/runtime/helpers/getEdgeSide.js +16 -0
- package/dist/runtime/helpers/getFrameById.d.ts +0 -0
- package/dist/runtime/helpers/getFrameById.js +5 -0
- package/dist/runtime/helpers/getFrameConstant.d.ts +0 -0
- package/dist/runtime/helpers/getFrameConstant.js +15 -0
- package/dist/runtime/helpers/getIntersections.d.ts +0 -0
- package/dist/runtime/helpers/getIntersections.js +63 -0
- package/dist/runtime/helpers/getIntersectionsCss.d.ts +0 -0
- package/dist/runtime/helpers/getIntersectionsCss.js +56 -0
- package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +0 -0
- package/dist/runtime/helpers/getMoveEdgeInfo.js +42 -0
- package/dist/runtime/helpers/getResizeLimit.d.ts +0 -0
- package/dist/runtime/helpers/getResizeLimit.js +39 -0
- package/dist/runtime/helpers/getShapeSquareCss.d.ts +0 -0
- package/dist/runtime/helpers/getShapeSquareCss.js +17 -0
- package/dist/runtime/helpers/getSideTouching.d.ts +0 -0
- package/dist/runtime/helpers/getSideTouching.js +7 -0
- package/dist/runtime/helpers/getVisualEdgeCss.d.ts +0 -0
- package/dist/runtime/helpers/getVisualEdgeCss.js +40 -0
- package/dist/runtime/helpers/getVisualEdges.d.ts +0 -0
- package/dist/runtime/helpers/getVisualEdges.js +89 -0
- package/dist/runtime/helpers/getVisualEdgesCss.d.ts +0 -0
- package/dist/runtime/helpers/getVisualEdgesCss.js +4 -0
- package/dist/runtime/helpers/getWinAndFrameById.d.ts +0 -0
- package/dist/runtime/helpers/getWinAndFrameById.js +14 -0
- package/dist/runtime/helpers/getWinByFrameUuid.d.ts +0 -0
- package/dist/runtime/helpers/getWinByFrameUuid.js +13 -0
- package/dist/runtime/helpers/getWinById.d.ts +0 -0
- package/dist/runtime/helpers/getWinById.js +5 -0
- package/dist/runtime/helpers/getWindowConstant.d.ts +0 -0
- package/dist/runtime/helpers/getWindowConstant.js +14 -0
- package/dist/runtime/helpers/inRange.d.ts +0 -0
- package/dist/runtime/helpers/inRange.js +3 -0
- package/dist/runtime/helpers/index.d.ts +0 -0
- package/dist/runtime/helpers/index.js +62 -0
- package/dist/runtime/helpers/isEdgeEqual.d.ts +0 -0
- package/dist/runtime/helpers/isEdgeEqual.js +11 -0
- package/dist/runtime/helpers/isEdgeParallel.d.ts +0 -0
- package/dist/runtime/helpers/isEdgeParallel.js +7 -0
- package/dist/runtime/helpers/isPointEqual.d.ts +0 -0
- package/dist/runtime/helpers/isPointEqual.js +3 -0
- package/dist/runtime/helpers/isSizeAboveMin.d.ts +0 -0
- package/dist/runtime/helpers/isSizeAboveMin.js +3 -0
- package/dist/runtime/helpers/isSizeEqual.d.ts +0 -0
- package/dist/runtime/helpers/isSizeEqual.js +3 -0
- package/dist/runtime/helpers/isWindowEdge.d.ts +0 -0
- package/dist/runtime/helpers/isWindowEdge.js +7 -0
- package/dist/runtime/helpers/isWindowEdgePoint.d.ts +0 -0
- package/dist/runtime/helpers/isWindowEdgePoint.js +5 -0
- package/dist/runtime/helpers/moveEdge.d.ts +0 -0
- package/dist/runtime/helpers/moveEdge.js +8 -0
- package/dist/runtime/helpers/numberToScaledPercent.d.ts +0 -0
- package/dist/runtime/helpers/numberToScaledPercent.js +5 -0
- package/dist/runtime/helpers/numberToScaledSize.d.ts +0 -0
- package/dist/runtime/helpers/numberToScaledSize.js +19 -0
- package/dist/runtime/helpers/oppositeSide.d.ts +0 -0
- package/dist/runtime/helpers/oppositeSide.js +30 -0
- package/dist/runtime/helpers/resizeByEdge.d.ts +0 -0
- package/dist/runtime/helpers/resizeByEdge.js +29 -0
- package/dist/runtime/helpers/sideToDirection.d.ts +0 -0
- package/dist/runtime/helpers/sideToDirection.js +11 -0
- package/dist/runtime/helpers/sideToOrientation.d.ts +0 -0
- package/dist/runtime/helpers/sideToOrientation.js +10 -0
- package/dist/runtime/helpers/splitEdge.d.ts +0 -0
- package/dist/runtime/helpers/splitEdge.js +20 -0
- package/dist/runtime/helpers/toCoord.d.ts +0 -0
- package/dist/runtime/helpers/toCoord.js +10 -0
- package/dist/runtime/helpers/toId.d.ts +0 -0
- package/dist/runtime/helpers/toId.js +4 -0
- package/dist/runtime/helpers/toWindowCoord.d.ts +0 -0
- package/dist/runtime/helpers/toWindowCoord.js +14 -0
- package/dist/runtime/helpers/unionEdges.d.ts +0 -0
- package/dist/runtime/helpers/unionEdges.js +8 -0
- package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +0 -0
- package/dist/runtime/helpers/updateWindowSizeWithEvent.js +8 -0
- package/dist/runtime/index.d.ts +0 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/layout/closeFrame.d.ts +0 -0
- package/dist/runtime/layout/closeFrame.js +13 -0
- package/dist/runtime/layout/closeFrames.d.ts +0 -0
- package/dist/runtime/layout/closeFrames.js +8 -0
- package/dist/runtime/layout/createSplitDecoEdge.d.ts +0 -0
- package/dist/runtime/layout/createSplitDecoEdge.js +24 -0
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +0 -0
- package/dist/runtime/layout/createSplitDecoFromDrag.js +14 -0
- package/dist/runtime/layout/debugFrame.d.ts +0 -0
- package/dist/runtime/layout/debugFrame.js +4 -0
- package/dist/runtime/layout/findFramesTouchingEdge.d.ts +0 -0
- package/dist/runtime/layout/findFramesTouchingEdge.js +33 -0
- package/dist/runtime/layout/findSafeSplitEdge.d.ts +0 -0
- package/dist/runtime/layout/findSafeSplitEdge.js +20 -0
- package/dist/runtime/layout/findVisualEdge.d.ts +0 -0
- package/dist/runtime/layout/findVisualEdge.js +9 -0
- package/dist/runtime/layout/frameCreate.d.ts +0 -0
- package/dist/runtime/layout/frameCreate.js +13 -0
- package/dist/runtime/layout/frameSplit.d.ts +0 -0
- package/dist/runtime/layout/frameSplit.js +9 -0
- package/dist/runtime/layout/getCloseFrameInfo.d.ts +0 -0
- package/dist/runtime/layout/getCloseFrameInfo.js +103 -0
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +0 -0
- package/dist/runtime/layout/getFrameSplitInfo.js +40 -0
- package/dist/runtime/layout/getFrameTo.d.ts +0 -0
- package/dist/runtime/layout/getFrameTo.js +47 -0
- package/dist/runtime/layout/index.d.ts +0 -0
- package/dist/runtime/layout/index.js +22 -0
- package/dist/runtime/layout/isPointInFrame.d.ts +0 -0
- package/dist/runtime/layout/isPointInFrame.js +4 -0
- package/dist/runtime/layout/layoutAddWindow.d.ts +0 -0
- package/dist/runtime/layout/layoutAddWindow.js +4 -0
- package/dist/runtime/layout/layoutCreate.d.ts +0 -0
- package/dist/runtime/layout/layoutCreate.js +7 -0
- package/dist/runtime/layout/layoutRemoveWindow.d.ts +0 -0
- package/dist/runtime/layout/layoutRemoveWindow.js +5 -0
- package/dist/runtime/layout/resizeFrame.d.ts +0 -0
- package/dist/runtime/layout/resizeFrame.js +69 -0
- package/dist/runtime/layout/windowAddFrame.d.ts +0 -0
- package/dist/runtime/layout/windowAddFrame.js +4 -0
- package/dist/runtime/layout/windowCreate.d.ts +0 -0
- package/dist/runtime/layout/windowCreate.js +13 -0
- package/dist/runtime/layout/windowRemoveFrame.d.ts +0 -0
- package/dist/runtime/layout/windowRemoveFrame.js +5 -0
- package/dist/runtime/layout/windowSetActiveFrame.d.ts +0 -0
- package/dist/runtime/layout/windowSetActiveFrame.js +5 -0
- package/dist/runtime/settings.d.ts +0 -0
- package/dist/runtime/settings.js +54 -0
- package/dist/runtime/types/index.d.ts +0 -0
- package/dist/runtime/types/index.js +120 -0
- package/dist/runtime/utils/KnownError.d.ts +0 -0
- package/dist/runtime/utils/KnownError.js +9 -0
- package/dist/types.d.mts +5 -0
- package/package.json +153 -0
- package/src/module.ts +43 -0
- package/src/runtime/components/LayoutDecos.vue +62 -0
- package/src/runtime/components/LayoutEdges.vue +172 -0
- package/src/runtime/components/LayoutFrame.vue +47 -0
- package/src/runtime/components/LayoutShapeSquare.vue +38 -0
- package/src/runtime/components/LayoutWindow.vue +223 -0
- package/src/runtime/composables/useFrames.ts +251 -0
- package/src/runtime/demo/App.vue +139 -0
- package/src/runtime/demo/DemoControls.vue +17 -0
- package/src/runtime/demo/README.md +1 -0
- package/src/runtime/demo/main.ts +9 -0
- package/src/runtime/demo/sharedLayoutInstance.ts +7 -0
- package/src/runtime/demo/tailwind.css +4 -0
- package/src/runtime/drag/CloseAction.ts +158 -0
- package/src/runtime/drag/DragActionHandler.ts +146 -0
- package/src/runtime/drag/DragDirectionStore.ts +63 -0
- package/src/runtime/drag/SplitAction.ts +147 -0
- package/src/runtime/drag/types.ts +107 -0
- package/src/runtime/helpers/addPointsToIntersection.ts +9 -0
- package/src/runtime/helpers/assertEdgeSorted.ts +11 -0
- package/src/runtime/helpers/assertItemIn.ts +13 -0
- package/src/runtime/helpers/assertItemNotIn.ts +10 -0
- package/src/runtime/helpers/assertLayoutHasActiveWindow.ts +9 -0
- package/src/runtime/helpers/assertValidWinAndFrame.ts +16 -0
- package/src/runtime/helpers/assertValidWinAndFrameIds.ts +9 -0
- package/src/runtime/helpers/assertWindowHasActiveFrame.ts +9 -0
- package/src/runtime/helpers/clampNumber.ts +9 -0
- package/src/runtime/helpers/cloneFrame.ts +5 -0
- package/src/runtime/helpers/cloneFrames.ts +20 -0
- package/src/runtime/helpers/containsEdge.ts +16 -0
- package/src/runtime/helpers/convertLayoutWindowToWorkspace.ts +18 -0
- package/src/runtime/helpers/copySize.ts +7 -0
- package/src/runtime/helpers/createEdge.ts +19 -0
- package/src/runtime/helpers/dirToOrientation.ts +12 -0
- package/src/runtime/helpers/dirToSide.ts +7 -0
- package/src/runtime/helpers/doEdgesOverlap.ts +25 -0
- package/src/runtime/helpers/doesEdgeContinueEdge.ts +20 -0
- package/src/runtime/helpers/edgeToPoints.ts +5 -0
- package/src/runtime/helpers/findDraggableEdge.ts +24 -0
- package/src/runtime/helpers/findFrameDraggableEdges.ts +32 -0
- package/src/runtime/helpers/frameToEdges.ts +32 -0
- package/src/runtime/helpers/frameToPoints.ts +14 -0
- package/src/runtime/helpers/getEdgeOrientation.ts +6 -0
- package/src/runtime/helpers/getEdgeSharedDirection.ts +10 -0
- package/src/runtime/helpers/getEdgeSide.ts +27 -0
- package/src/runtime/helpers/getFrameById.ts +15 -0
- package/src/runtime/helpers/getFrameConstant.ts +22 -0
- package/src/runtime/helpers/getIntersections.ts +87 -0
- package/src/runtime/helpers/getIntersectionsCss.ts +65 -0
- package/src/runtime/helpers/getMoveEdgeInfo.ts +69 -0
- package/src/runtime/helpers/getResizeLimit.ts +60 -0
- package/src/runtime/helpers/getShapeSquareCss.ts +28 -0
- package/src/runtime/helpers/getSideTouching.ts +9 -0
- package/src/runtime/helpers/getVisualEdgeCss.ts +53 -0
- package/src/runtime/helpers/getVisualEdges.ts +155 -0
- package/src/runtime/helpers/getVisualEdgesCss.ts +13 -0
- package/src/runtime/helpers/getWinAndFrameById.ts +28 -0
- package/src/runtime/helpers/getWinByFrameUuid.ts +19 -0
- package/src/runtime/helpers/getWinById.ts +12 -0
- package/src/runtime/helpers/getWindowConstant.ts +21 -0
- package/src/runtime/helpers/inRange.ts +5 -0
- package/src/runtime/helpers/index.ts +64 -0
- package/src/runtime/helpers/isEdgeEqual.ts +14 -0
- package/src/runtime/helpers/isEdgeParallel.ts +10 -0
- package/src/runtime/helpers/isPointEqual.ts +5 -0
- package/src/runtime/helpers/isSizeAboveMin.ts +8 -0
- package/src/runtime/helpers/isSizeEqual.ts +5 -0
- package/src/runtime/helpers/isWindowEdge.ts +11 -0
- package/src/runtime/helpers/isWindowEdgePoint.ts +8 -0
- package/src/runtime/helpers/moveEdge.ts +21 -0
- package/src/runtime/helpers/numberToScaledPercent.ts +19 -0
- package/src/runtime/helpers/numberToScaledSize.ts +28 -0
- package/src/runtime/helpers/oppositeSide.ts +45 -0
- package/src/runtime/helpers/resizeByEdge.ts +45 -0
- package/src/runtime/helpers/sideToDirection.ts +15 -0
- package/src/runtime/helpers/sideToOrientation.ts +12 -0
- package/src/runtime/helpers/splitEdge.ts +23 -0
- package/src/runtime/helpers/toCoord.ts +13 -0
- package/src/runtime/helpers/toId.ts +9 -0
- package/src/runtime/helpers/toWindowCoord.ts +23 -0
- package/src/runtime/helpers/unionEdges.ts +11 -0
- package/src/runtime/helpers/updateWindowSizeWithEvent.ts +10 -0
- package/src/runtime/index.ts +5 -0
- package/src/runtime/layout/closeFrame.ts +33 -0
- package/src/runtime/layout/closeFrames.ts +14 -0
- package/src/runtime/layout/createSplitDecoEdge.ts +34 -0
- package/src/runtime/layout/createSplitDecoFromDrag.ts +24 -0
- package/src/runtime/layout/debugFrame.ts +6 -0
- package/src/runtime/layout/findFramesTouchingEdge.ts +92 -0
- package/src/runtime/layout/findSafeSplitEdge.ts +39 -0
- package/src/runtime/layout/findVisualEdge.ts +11 -0
- package/src/runtime/layout/frameCreate.ts +23 -0
- package/src/runtime/layout/frameSplit.ts +31 -0
- package/src/runtime/layout/getCloseFrameInfo.ts +193 -0
- package/src/runtime/layout/getFrameSplitInfo.ts +65 -0
- package/src/runtime/layout/getFrameTo.ts +65 -0
- package/src/runtime/layout/index.ts +24 -0
- package/src/runtime/layout/isPointInFrame.ts +7 -0
- package/src/runtime/layout/layoutAddWindow.ts +6 -0
- package/src/runtime/layout/layoutCreate.ts +12 -0
- package/src/runtime/layout/layoutRemoveWindow.ts +7 -0
- package/src/runtime/layout/resizeFrame.ts +106 -0
- package/src/runtime/layout/windowAddFrame.ts +10 -0
- package/src/runtime/layout/windowCreate.ts +18 -0
- package/src/runtime/layout/windowRemoveFrame.ts +7 -0
- package/src/runtime/layout/windowSetActiveFrame.ts +7 -0
- package/src/runtime/settings.ts +63 -0
- package/src/runtime/types/index.ts +293 -0
- package/src/runtime/utils/KnownError.ts +24 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { multisplice, MULTISPLICE_ITEM } from "@alanscodelog/utils/multisplice";
|
|
2
|
+
import { addPointsToIntersection } from "./addPointsToIntersection.js";
|
|
3
|
+
import { assertEdgeSorted } from "./assertEdgeSorted.js";
|
|
4
|
+
import { containsEdge } from "./containsEdge.js";
|
|
5
|
+
import { doEdgesOverlap } from "./doEdgesOverlap.js";
|
|
6
|
+
import { frameToEdges } from "./frameToEdges.js";
|
|
7
|
+
import { frameToPoints } from "./frameToPoints.js";
|
|
8
|
+
import { inRange } from "./inRange.js";
|
|
9
|
+
import { splitEdge } from "./splitEdge.js";
|
|
10
|
+
import { unionEdges } from "./unionEdges.js";
|
|
11
|
+
import { getMaxInt } from "../settings.js";
|
|
12
|
+
export function getVisualEdges(frames, {
|
|
13
|
+
separateByDir = false,
|
|
14
|
+
includeWindowEdges = false
|
|
15
|
+
} = {}) {
|
|
16
|
+
let extVertEdges = [];
|
|
17
|
+
let extHorzEdges = [];
|
|
18
|
+
const intersections = {
|
|
19
|
+
// x: {y: count}
|
|
20
|
+
};
|
|
21
|
+
const max = getMaxInt();
|
|
22
|
+
for (const frame of frames) {
|
|
23
|
+
const frameEdges = frameToEdges(frame);
|
|
24
|
+
addPointsToIntersection(intersections, Object.values(frameToPoints(frame)));
|
|
25
|
+
secondlabel: for (const edge of Object.values(frameEdges)) {
|
|
26
|
+
const dir = edge === frameEdges.left || edge === frameEdges.right ? "vertical" : "horizontal";
|
|
27
|
+
const startKey = dir === "vertical" ? "startX" : "startY";
|
|
28
|
+
const endKey = dir === "vertical" ? "endX" : "endY";
|
|
29
|
+
const arr = dir === "vertical" ? extVertEdges : extHorzEdges;
|
|
30
|
+
const indexes = [];
|
|
31
|
+
const edges = [];
|
|
32
|
+
for (const [i, e] of arr.entries()) {
|
|
33
|
+
if (containsEdge(edge, e, dir)) {
|
|
34
|
+
continue secondlabel;
|
|
35
|
+
}
|
|
36
|
+
if (doEdgesOverlap(e, edge, dir)) {
|
|
37
|
+
indexes.push(i);
|
|
38
|
+
edges.push(e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (indexes.length > 0) {
|
|
42
|
+
multisplice(arr, indexes, 1);
|
|
43
|
+
edges.push(edge);
|
|
44
|
+
const newEdge = unionEdges(edges, dir);
|
|
45
|
+
arr.push(newEdge);
|
|
46
|
+
} else if (includeWindowEdges || edge[startKey] !== 0 && edge[endKey] !== max) {
|
|
47
|
+
arr.push(edge);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const changesV = {};
|
|
52
|
+
for (const [i, edge] of extVertEdges.entries()) {
|
|
53
|
+
const possibleIntersections = intersections[edge.startX];
|
|
54
|
+
assertEdgeSorted(edge);
|
|
55
|
+
if (possibleIntersections) {
|
|
56
|
+
const splits = Object.keys(possibleIntersections).filter((_y) => {
|
|
57
|
+
const y = Number.parseInt(_y, 10);
|
|
58
|
+
const isIntersection = possibleIntersections[_y] === 4;
|
|
59
|
+
return isIntersection && inRange(y, edge.startY, edge.endY);
|
|
60
|
+
}).map((_) => Number.parseInt(_, 10));
|
|
61
|
+
if (splits.length === 0) continue;
|
|
62
|
+
changesV[i] = splitEdge(extVertEdges[i], "vertical", splits);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
extVertEdges = multisplice(
|
|
66
|
+
extVertEdges,
|
|
67
|
+
Object.keys(changesV),
|
|
68
|
+
1,
|
|
69
|
+
Object.values(changesV),
|
|
70
|
+
{ insert: MULTISPLICE_ITEM.MATCH_INDEX }
|
|
71
|
+
).array.flat();
|
|
72
|
+
const changesH = {};
|
|
73
|
+
for (const [i, edge] of extHorzEdges.entries()) {
|
|
74
|
+
const splits = Object.keys(intersections).filter((x) => intersections[x][edge.startY] === 4).map((_) => Number.parseInt(_, 10));
|
|
75
|
+
if (splits.length === 0) continue;
|
|
76
|
+
changesH[i] = splitEdge(extHorzEdges[i], "horizontal", splits);
|
|
77
|
+
}
|
|
78
|
+
extHorzEdges = multisplice(
|
|
79
|
+
extHorzEdges,
|
|
80
|
+
Object.keys(changesH),
|
|
81
|
+
1,
|
|
82
|
+
Object.values(changesH),
|
|
83
|
+
{ insert: MULTISPLICE_ITEM.MATCH_INDEX }
|
|
84
|
+
).array.flat();
|
|
85
|
+
if (separateByDir) {
|
|
86
|
+
return { vertical: extVertEdges, horizontal: extHorzEdges };
|
|
87
|
+
}
|
|
88
|
+
return extVertEdges.concat(extHorzEdges);
|
|
89
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getFrameConstant } from "./getFrameConstant.js";
|
|
2
|
+
import { getWinByFrameUuid } from "./getWinByFrameUuid.js";
|
|
3
|
+
import { getWindowConstant } from "./getWindowConstant.js";
|
|
4
|
+
export function getWinAndFrameById(layout, winId, frameId, assert = false) {
|
|
5
|
+
let win;
|
|
6
|
+
if (winId === void 0) {
|
|
7
|
+
win = getWinByFrameUuid(layout, frameId, assert);
|
|
8
|
+
} else {
|
|
9
|
+
win = layout.windows[getWindowConstant(layout, winId, assert)];
|
|
10
|
+
}
|
|
11
|
+
const maybeFrameId = win !== void 0 ? getFrameConstant(win, frameId, assert) : void 0;
|
|
12
|
+
const frame = win?.frames[maybeFrameId];
|
|
13
|
+
return { win, frame };
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LAYOUT_ERROR } from "../types/index.js";
|
|
2
|
+
import { KnownError } from "../utils/KnownError.js";
|
|
3
|
+
export function getWinByFrameUuid(layout, frameId, assert = false) {
|
|
4
|
+
for (const win of Object.values(layout.windows)) {
|
|
5
|
+
if (win.frames[frameId]) {
|
|
6
|
+
return win;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
if (assert) {
|
|
10
|
+
throw new KnownError(LAYOUT_ERROR.INVALID_ID, "Could not find window with frame with that id.", { id: frameId });
|
|
11
|
+
}
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { assertItemIn } from "./assertItemIn.js";
|
|
2
|
+
import { assertLayoutHasActiveWindow } from "./assertLayoutHasActiveWindow.js";
|
|
3
|
+
export function getWindowConstant(layout, constant, assert = false) {
|
|
4
|
+
switch (constant) {
|
|
5
|
+
case "ACTIVE": {
|
|
6
|
+
if (assert) assertLayoutHasActiveWindow(layout);
|
|
7
|
+
return layout.activeWindow;
|
|
8
|
+
}
|
|
9
|
+
default: {
|
|
10
|
+
if (assert) assertItemIn(layout.windows, constant);
|
|
11
|
+
return constant;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export { addPointsToIntersection } from "./addPointsToIntersection.js";
|
|
2
|
+
export { assertEdgeSorted } from "./assertEdgeSorted.js";
|
|
3
|
+
export { assertItemIn } from "./assertItemIn.js";
|
|
4
|
+
export { assertItemNotIn } from "./assertItemNotIn.js";
|
|
5
|
+
export { assertLayoutHasActiveWindow } from "./assertLayoutHasActiveWindow.js";
|
|
6
|
+
export { assertValidWinAndFrame } from "./assertValidWinAndFrame.js";
|
|
7
|
+
export { assertValidWinAndFrameIds } from "./assertValidWinAndFrameIds.js";
|
|
8
|
+
export { assertWindowHasActiveFrame } from "./assertWindowHasActiveFrame.js";
|
|
9
|
+
export { clampNumber } from "./clampNumber.js";
|
|
10
|
+
export { cloneFrame } from "./cloneFrame.js";
|
|
11
|
+
export { cloneFrames } from "./cloneFrames.js";
|
|
12
|
+
export { containsEdge } from "./containsEdge.js";
|
|
13
|
+
export { convertLayoutWindowToWorkspace } from "./convertLayoutWindowToWorkspace.js";
|
|
14
|
+
export { copySize } from "./copySize.js";
|
|
15
|
+
export { createEdge } from "./createEdge.js";
|
|
16
|
+
export { dirToOrientation } from "./dirToOrientation.js";
|
|
17
|
+
export { dirToSide } from "./dirToSide.js";
|
|
18
|
+
export { doEdgesOverlap } from "./doEdgesOverlap.js";
|
|
19
|
+
export { doesEdgeContinueEdge } from "./doesEdgeContinueEdge.js";
|
|
20
|
+
export { edgeToPoints } from "./edgeToPoints.js";
|
|
21
|
+
export { findDraggableEdge } from "./findDraggableEdge.js";
|
|
22
|
+
export { findFrameDraggableEdges } from "./findFrameDraggableEdges.js";
|
|
23
|
+
export { frameToEdges } from "./frameToEdges.js";
|
|
24
|
+
export { frameToPoints } from "./frameToPoints.js";
|
|
25
|
+
export { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
26
|
+
export { getEdgeSharedDirection } from "./getEdgeSharedDirection.js";
|
|
27
|
+
export { getEdgeSide } from "./getEdgeSide.js";
|
|
28
|
+
export { getFrameById } from "./getFrameById.js";
|
|
29
|
+
export { getFrameConstant } from "./getFrameConstant.js";
|
|
30
|
+
export { getIntersections } from "./getIntersections.js";
|
|
31
|
+
export { getIntersectionsCss } from "./getIntersectionsCss.js";
|
|
32
|
+
export { getMoveEdgeInfo } from "./getMoveEdgeInfo.js";
|
|
33
|
+
export { getResizeLimit } from "./getResizeLimit.js";
|
|
34
|
+
export { getShapeSquareCss } from "./getShapeSquareCss.js";
|
|
35
|
+
export { getSideTouching } from "./getSideTouching.js";
|
|
36
|
+
export { getVisualEdgeCss } from "./getVisualEdgeCss.js";
|
|
37
|
+
export { getVisualEdges } from "./getVisualEdges.js";
|
|
38
|
+
export { getVisualEdgesCss } from "./getVisualEdgesCss.js";
|
|
39
|
+
export { getWinAndFrameById } from "./getWinAndFrameById.js";
|
|
40
|
+
export { getWinByFrameUuid } from "./getWinByFrameUuid.js";
|
|
41
|
+
export { getWinById } from "./getWinById.js";
|
|
42
|
+
export { getWindowConstant } from "./getWindowConstant.js";
|
|
43
|
+
export { inRange } from "./inRange.js";
|
|
44
|
+
export { isEdgeEqual } from "./isEdgeEqual.js";
|
|
45
|
+
export { isEdgeParallel } from "./isEdgeParallel.js";
|
|
46
|
+
export { isPointEqual } from "./isPointEqual.js";
|
|
47
|
+
export { isSizeAboveMin } from "./isSizeAboveMin.js";
|
|
48
|
+
export { isSizeEqual } from "./isSizeEqual.js";
|
|
49
|
+
export { isWindowEdge } from "./isWindowEdge.js";
|
|
50
|
+
export { isWindowEdgePoint } from "./isWindowEdgePoint.js";
|
|
51
|
+
export { moveEdge } from "./moveEdge.js";
|
|
52
|
+
export { numberToScaledPercent } from "./numberToScaledPercent.js";
|
|
53
|
+
export { numberToScaledSize } from "./numberToScaledSize.js";
|
|
54
|
+
export { oppositeSide } from "./oppositeSide.js";
|
|
55
|
+
export { resizeByEdge } from "./resizeByEdge.js";
|
|
56
|
+
export { sideToDirection } from "./sideToDirection.js";
|
|
57
|
+
export { sideToOrientation } from "./sideToOrientation.js";
|
|
58
|
+
export { splitEdge } from "./splitEdge.js";
|
|
59
|
+
export { toCoord } from "./toCoord.js";
|
|
60
|
+
export { toId } from "./toId.js";
|
|
61
|
+
export { toWindowCoord } from "./toWindowCoord.js";
|
|
62
|
+
export { unionEdges } from "./unionEdges.js";
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { isEdgeParallel } from "./isEdgeParallel.js";
|
|
3
|
+
export function isEdgeEqual(edgeA, edgeB, orientation) {
|
|
4
|
+
orientation ??= getEdgeOrientation(edgeA);
|
|
5
|
+
if (!isEdgeParallel(edgeA, edgeB)) return false;
|
|
6
|
+
if (orientation === "horizontal") {
|
|
7
|
+
return edgeA.startY === edgeB.startY && edgeB.endY === edgeA.endY;
|
|
8
|
+
} else {
|
|
9
|
+
return edgeA.startX === edgeB.startX && edgeB.endX === edgeA.endX;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getEdgeSharedDirection } from "./getEdgeSharedDirection.js";
|
|
2
|
+
export function isEdgeParallel(edgeA, edgeB, dir) {
|
|
3
|
+
const sharedDir = getEdgeSharedDirection(edgeA, edgeB);
|
|
4
|
+
if (dir === void 0) return sharedDir !== false;
|
|
5
|
+
if (dir === sharedDir) return true;
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { getMaxInt } from "../settings.js";
|
|
3
|
+
export function isWindowEdge(edge, edgeDirection) {
|
|
4
|
+
edgeDirection ??= getEdgeOrientation(edge);
|
|
5
|
+
const max = getMaxInt();
|
|
6
|
+
return edgeDirection === "vertical" && (edge.startX === 0 || edge.startX === max) || edgeDirection === "horizontal" && (edge.startY === 0 || edge.startY === max);
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getMoveEdgeInfo } from "./getMoveEdgeInfo.js";
|
|
2
|
+
import { resizeByEdge } from "./resizeByEdge.js";
|
|
3
|
+
import { getMarginSize } from "../settings.js";
|
|
4
|
+
export function moveEdge(touchingFrames, edge, position, margin = getMarginSize()) {
|
|
5
|
+
if (!edge || !touchingFrames) return;
|
|
6
|
+
const { pos, dir, distance } = getMoveEdgeInfo(touchingFrames, edge, position, margin);
|
|
7
|
+
resizeByEdge(touchingFrames, edge, dir, pos, distance);
|
|
8
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
|
+
import { numberToScaledPercent } from "./numberToScaledPercent.js";
|
|
3
|
+
import { getMaxInt } from "../settings.js";
|
|
4
|
+
export function numberToScaledSize(win, size, scale = getMaxInt()) {
|
|
5
|
+
const scaledSize = {
|
|
6
|
+
width: numberToScaledPercent(
|
|
7
|
+
typeof size === "number" ? size : size.pxWidth,
|
|
8
|
+
win.pxWidth,
|
|
9
|
+
scale
|
|
10
|
+
),
|
|
11
|
+
height: numberToScaledPercent(
|
|
12
|
+
typeof size === "number" ? size : size.pxHeight,
|
|
13
|
+
win.pxHeight,
|
|
14
|
+
scale
|
|
15
|
+
)
|
|
16
|
+
};
|
|
17
|
+
if (scaledSize.width > scale) unreachable();
|
|
18
|
+
return scaledSize;
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
|
+
export function oppositeSide(dir) {
|
|
3
|
+
switch (dir) {
|
|
4
|
+
case "x":
|
|
5
|
+
return "y";
|
|
6
|
+
case "y":
|
|
7
|
+
return "x";
|
|
8
|
+
case "width":
|
|
9
|
+
return "height";
|
|
10
|
+
case "height":
|
|
11
|
+
return "width";
|
|
12
|
+
case "left":
|
|
13
|
+
return "right";
|
|
14
|
+
case "right":
|
|
15
|
+
return "left";
|
|
16
|
+
case "up":
|
|
17
|
+
return "down";
|
|
18
|
+
case "top":
|
|
19
|
+
return "bottom";
|
|
20
|
+
case "bottom":
|
|
21
|
+
return "top";
|
|
22
|
+
case "down":
|
|
23
|
+
return "up";
|
|
24
|
+
case "horizontal":
|
|
25
|
+
return "vertical";
|
|
26
|
+
case "vertical":
|
|
27
|
+
return "horizontal";
|
|
28
|
+
}
|
|
29
|
+
unreachable();
|
|
30
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function resizeByEdge(touchingFrames, edge, dir, newPos, distance) {
|
|
2
|
+
if (distance === 0) return;
|
|
3
|
+
for (const frame of touchingFrames) {
|
|
4
|
+
if (dir === "up" || dir === "down") {
|
|
5
|
+
const isAbove = frame.y < edge.startY;
|
|
6
|
+
if (isAbove) {
|
|
7
|
+
frame.height = newPos - frame.y;
|
|
8
|
+
} else {
|
|
9
|
+
frame.height = frame.y + frame.height - newPos;
|
|
10
|
+
frame.y = newPos;
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
const isLeft = frame.x < edge.startX;
|
|
14
|
+
if (isLeft) {
|
|
15
|
+
frame.width = newPos - frame.x;
|
|
16
|
+
} else {
|
|
17
|
+
frame.width = frame.x + frame.width - newPos;
|
|
18
|
+
frame.x = newPos;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (dir === "up" || dir === "down") {
|
|
23
|
+
edge.startY = newPos;
|
|
24
|
+
edge.endY = newPos;
|
|
25
|
+
} else {
|
|
26
|
+
edge.startX = newPos;
|
|
27
|
+
edge.endX = newPos;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { last } from "@alanscodelog/utils/last";
|
|
2
|
+
export function splitEdge(edge, edgeDirection, splits) {
|
|
3
|
+
const startKey = edgeDirection === "horizontal" ? "startX" : "startY";
|
|
4
|
+
const endKey = edgeDirection === "horizontal" ? "endX" : "endY";
|
|
5
|
+
const newEdges = [];
|
|
6
|
+
if (splits.length === 0) throw new Error("There must be at least one split position.");
|
|
7
|
+
for (const [i, splitPos] of splits.entries()) {
|
|
8
|
+
if (i === 0) {
|
|
9
|
+
newEdges.push({ ...edge, [startKey]: edge[startKey], [endKey]: splitPos });
|
|
10
|
+
} else {
|
|
11
|
+
const prevEdge2 = newEdges[i - 1];
|
|
12
|
+
newEdges.push({ ...prevEdge2, [startKey]: prevEdge2[endKey], [endKey]: splitPos });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const prevEdge = last(newEdges);
|
|
16
|
+
if (prevEdge[endKey] !== edge[endKey]) {
|
|
17
|
+
newEdges.push({ ...prevEdge, [startKey]: prevEdge[endKey], [endKey]: edge[endKey] });
|
|
18
|
+
}
|
|
19
|
+
return newEdges;
|
|
20
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { snapNumber } from "@alanscodelog/utils/snapNumber";
|
|
2
|
+
import { numberToScaledPercent } from "./numberToScaledPercent.js";
|
|
3
|
+
import { getSnapPoint } from "../settings.js";
|
|
4
|
+
export function toWindowCoord(win, e, snapAmount = getSnapPoint()) {
|
|
5
|
+
const x = numberToScaledPercent(e.clientX - win.pxX, win.pxWidth);
|
|
6
|
+
const y = numberToScaledPercent(e.clientY - win.pxY, win.pxHeight);
|
|
7
|
+
if (snapAmount) {
|
|
8
|
+
return {
|
|
9
|
+
x: snapNumber(x, snapAmount.x),
|
|
10
|
+
y: snapNumber(y, snapAmount.x)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return { x, y };
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { last } from "@alanscodelog/utils/last";
|
|
2
|
+
export function unionEdges(edges, dir) {
|
|
3
|
+
const startKey = dir === "horizontal" ? "startX" : "startY";
|
|
4
|
+
const endKey = dir === "horizontal" ? "endX" : "endY";
|
|
5
|
+
edges.sort((a, b) => a[startKey] - b[startKey]);
|
|
6
|
+
const newEdge = { ...edges[0], [startKey]: edges[0][startKey], [endKey]: last(edges)[endKey] };
|
|
7
|
+
return newEdge;
|
|
8
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { closeFrames } from "./closeFrames.js";
|
|
2
|
+
import { getCloseFrameInfo } from "./getCloseFrameInfo.js";
|
|
3
|
+
import { getMarginSize } from "../settings.js";
|
|
4
|
+
export function closeFrame(win, visualEdges, frame, closeDirOrSide, closeBy = "dir", force = false, minSize = getMarginSize()) {
|
|
5
|
+
const canClose = getCloseFrameInfo(Object.values(win.frames), visualEdges, frame, closeDirOrSide, closeBy, force, minSize);
|
|
6
|
+
if (canClose instanceof Error) {
|
|
7
|
+
return canClose;
|
|
8
|
+
}
|
|
9
|
+
const { deletedFrames, modifiedFrames } = canClose;
|
|
10
|
+
closeFrames(win, deletedFrames, modifiedFrames);
|
|
11
|
+
win.activeFrame = modifiedFrames[0].id;
|
|
12
|
+
return deletedFrames;
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { findSafeSplitEdgeAndPosition } from "./findSafeSplitEdge.js";
|
|
2
|
+
import { getMarginSize, getSnapPoint } from "../settings.js";
|
|
3
|
+
export function createSplitDecoEdge(frames, deco, snapAmount = getSnapPoint(), minSize = getMarginSize()) {
|
|
4
|
+
const frame = frames[deco.id];
|
|
5
|
+
const { edge, position } = findSafeSplitEdgeAndPosition(frame, deco.direction, deco.position, snapAmount, minSize);
|
|
6
|
+
const newFrame = { x: frame.x, y: frame.y, width: frame.width, height: frame.height };
|
|
7
|
+
switch (deco.direction) {
|
|
8
|
+
case "right":
|
|
9
|
+
newFrame.x = position;
|
|
10
|
+
newFrame.width = frame.x + frame.width - position;
|
|
11
|
+
break;
|
|
12
|
+
case "left":
|
|
13
|
+
newFrame.width = position - frame.x;
|
|
14
|
+
break;
|
|
15
|
+
case "down":
|
|
16
|
+
newFrame.y = position;
|
|
17
|
+
newFrame.height = frame.y + frame.height - position;
|
|
18
|
+
break;
|
|
19
|
+
case "up":
|
|
20
|
+
newFrame.height = position - frame.y;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return { edge, newFrame };
|
|
24
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createSplitDecoEdge } from "./createSplitDecoEdge.js";
|
|
2
|
+
import { dirToOrientation } from "../helpers/dirToOrientation.js";
|
|
3
|
+
import { getMarginSize, getSnapPoint } from "../settings.js";
|
|
4
|
+
export function createSplitDecoFromDrag(frames, frame, dragDirection, dragPoint, snapAmount = getSnapPoint(), minSize = getMarginSize()) {
|
|
5
|
+
const orientation = dirToOrientation(dragDirection);
|
|
6
|
+
const deco = {
|
|
7
|
+
type: "split",
|
|
8
|
+
id: frame.id,
|
|
9
|
+
position: dragPoint[orientation === "horizontal" ? "x" : "y"],
|
|
10
|
+
direction: dragDirection
|
|
11
|
+
};
|
|
12
|
+
deco.shapes = createSplitDecoEdge(frames, deco, snapAmount, minSize);
|
|
13
|
+
return deco;
|
|
14
|
+
}
|
|
File without changes
|
|
File without changes
|