@witchcraft/layout 1.0.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/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 +123 -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 +140 -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,33 @@
|
|
|
1
|
+
import { containsEdge } from "../helpers/containsEdge.js";
|
|
2
|
+
import { dirToSide } from "../helpers/dirToSide.js";
|
|
3
|
+
import { frameToEdges } from "../helpers/frameToEdges.js";
|
|
4
|
+
import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
|
|
5
|
+
import { inRange } from "../helpers/inRange.js";
|
|
6
|
+
import { oppositeSide } from "../helpers/oppositeSide.js";
|
|
7
|
+
import { toCoord } from "../helpers/toCoord.js";
|
|
8
|
+
export function findFramesTouchingEdge(edge, frames, criteria = {}) {
|
|
9
|
+
const visualEdge = edge;
|
|
10
|
+
const res = [];
|
|
11
|
+
const visualEdgeDirection = getEdgeOrientation(visualEdge);
|
|
12
|
+
const searchDirections = criteria.searchDirections ?? (visualEdgeDirection === "horizontal" ? ["up", "down"] : ["left", "right"]);
|
|
13
|
+
const frameSearchSides = searchDirections.map((dir) => oppositeSide(dirToSide(dir)));
|
|
14
|
+
const coord = toCoord(visualEdgeDirection);
|
|
15
|
+
const coordUpper = coord.toUpperCase();
|
|
16
|
+
for (const frame of frames) {
|
|
17
|
+
const frameEdges = frameToEdges(frame, frameSearchSides);
|
|
18
|
+
const edges = Object.entries(frameEdges);
|
|
19
|
+
for (const [side, edge2] of edges) {
|
|
20
|
+
if (containsEdge(edge2, visualEdge, visualEdgeDirection)) {
|
|
21
|
+
if (criteria.referencePoint) {
|
|
22
|
+
const isInRange = inRange(criteria.referencePoint[coord], edge2[`start${coordUpper}`], edge2[`end${coordUpper}`]);
|
|
23
|
+
if (isInRange) {
|
|
24
|
+
res.push({ edge: edge2, frame, side });
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
res.push({ edge: edge2, frame, side });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { clampNumber, snapNumber } from "@alanscodelog/utils";
|
|
2
|
+
import { dirToOrientation } from "../helpers/dirToOrientation.js";
|
|
3
|
+
import { oppositeSide } from "../helpers/oppositeSide.js";
|
|
4
|
+
import { getMarginSize, getSnapPoint } from "../settings.js";
|
|
5
|
+
export function findSafeSplitEdgeAndPosition(frame, dragDirection, dragPointOrPosition, snapAmount = getSnapPoint(), minSize = getMarginSize()) {
|
|
6
|
+
const orientation = dirToOrientation(dragDirection);
|
|
7
|
+
const position = typeof dragPointOrPosition === "number" ? dragPointOrPosition : dragPointOrPosition[orientation === "horizontal" ? "x" : "y"];
|
|
8
|
+
const coordKey = orientation === "vertical" ? "y" : "x";
|
|
9
|
+
const sizeKey = orientation === "vertical" ? "height" : "width";
|
|
10
|
+
const pos = snapNumber(position, snapAmount[coordKey]);
|
|
11
|
+
const lowerLimit = snapNumber(frame[coordKey] + minSize[sizeKey], snapAmount[coordKey], "floor");
|
|
12
|
+
const upperLimit = snapNumber(frame[coordKey] + frame[sizeKey] - minSize[sizeKey], snapAmount[coordKey], "floor");
|
|
13
|
+
const clampedPos = clampNumber(pos, lowerLimit, upperLimit);
|
|
14
|
+
const oppositeCoordKey = oppositeSide(coordKey);
|
|
15
|
+
const oppositeSizeKey = oppositeSide(sizeKey);
|
|
16
|
+
const frameStart = snapNumber(frame[oppositeCoordKey], snapAmount[oppositeCoordKey]);
|
|
17
|
+
const frameEnd = snapNumber(frameStart + frame[oppositeSizeKey], snapAmount[oppositeCoordKey]);
|
|
18
|
+
const edge = orientation === "vertical" ? { startY: clampedPos, endY: clampedPos, startX: frameStart, endX: frameEnd } : { startX: clampedPos, endX: clampedPos, startY: frameStart, endY: frameEnd };
|
|
19
|
+
return { edge, position: clampedPos };
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { containsEdge } from "../helpers/containsEdge.js";
|
|
2
|
+
import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
|
|
3
|
+
export function findVisualEdge(visualEdges, edge) {
|
|
4
|
+
const edgeDirection = getEdgeOrientation(edge);
|
|
5
|
+
for (const visualEdge of visualEdges) {
|
|
6
|
+
if (containsEdge(visualEdge, edge, edgeDirection)) return visualEdge;
|
|
7
|
+
}
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { getMaxInt } from "../settings.js";
|
|
3
|
+
export function frameCreate(opts = {}) {
|
|
4
|
+
const maxInt = getMaxInt();
|
|
5
|
+
return {
|
|
6
|
+
width: maxInt,
|
|
7
|
+
height: maxInt,
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
...opts,
|
|
11
|
+
id: opts.id ?? uuidv4()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { keys } from "@alanscodelog/utils/keys";
|
|
2
|
+
export function frameSplit(win, { splitFrame, newFrame }) {
|
|
3
|
+
const winFrame = win.frames[splitFrame.id];
|
|
4
|
+
for (const key of keys(splitFrame)) {
|
|
5
|
+
winFrame[key] = splitFrame[key];
|
|
6
|
+
}
|
|
7
|
+
win.frames[newFrame.id] = newFrame;
|
|
8
|
+
return newFrame;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
|
|
2
|
+
import { readable } from "@alanscodelog/utils/readable";
|
|
3
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
4
|
+
import { findFramesTouchingEdge } from "./findFramesTouchingEdge.js";
|
|
5
|
+
import { findVisualEdge } from "./findVisualEdge.js";
|
|
6
|
+
import { cloneFrame } from "../helpers/cloneFrame.js";
|
|
7
|
+
import { dirToSide } from "../helpers/dirToSide.js";
|
|
8
|
+
import { findFrameDraggableEdges } from "../helpers/findFrameDraggableEdges.js";
|
|
9
|
+
import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
|
|
10
|
+
import { oppositeSide } from "../helpers/oppositeSide.js";
|
|
11
|
+
import { getMarginSize } from "../settings.js";
|
|
12
|
+
import { LAYOUT_ERROR } from "../types/index.js";
|
|
13
|
+
import { KnownError } from "../utils/KnownError.js";
|
|
14
|
+
export function getCloseFrameInfo(frames, visualEdges, frame, closeDirOrSide, closeBy = "dir", force = false, minSize = getMarginSize()) {
|
|
15
|
+
if (frames.length === 1) {
|
|
16
|
+
return new KnownError(
|
|
17
|
+
LAYOUT_ERROR.CANT_CLOSE_SINGLE_FRAME,
|
|
18
|
+
`Can't close frame ${frame.id}, it is the last frame in the window.`,
|
|
19
|
+
{ frame }
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const side = closeBy === "dir" ? oppositeSide(dirToSide(closeDirOrSide)) : closeDirOrSide;
|
|
23
|
+
const sideOpposite = oppositeSide(side);
|
|
24
|
+
const draggableEdges = findFrameDraggableEdges(frame, visualEdges, !force, [side]);
|
|
25
|
+
if (!draggableEdges) return new KnownError(LAYOUT_ERROR.CANT_CLOSE_NO_DRAG_EDGE, `Could not find draggable edge for frame ${frame.id}`, { frame });
|
|
26
|
+
const { edge: frameEdge } = draggableEdges[0];
|
|
27
|
+
const visualEdge = findVisualEdge(visualEdges, frameEdge);
|
|
28
|
+
if (visualEdge === void 0) unreachable();
|
|
29
|
+
const direction = oppositeSide(getEdgeOrientation(visualEdge));
|
|
30
|
+
const entriesInVisualEdges = findFramesTouchingEdge(visualEdge, frames);
|
|
31
|
+
if (entriesInVisualEdges.length === 0) unreachable();
|
|
32
|
+
const sizeKey = direction === "horizontal" ? "width" : "height";
|
|
33
|
+
const coordKey = direction === "horizontal" ? "x" : "y";
|
|
34
|
+
const thisFrameSize = frame[sizeKey];
|
|
35
|
+
const frameSizes = [];
|
|
36
|
+
const oppositeSideEntries = [];
|
|
37
|
+
const sameSideEntries = [];
|
|
38
|
+
for (const _ of entriesInVisualEdges) {
|
|
39
|
+
if (_.side === side) {
|
|
40
|
+
sameSideEntries.push(_);
|
|
41
|
+
const size = _.frame[sizeKey];
|
|
42
|
+
pushIfNotIn(frameSizes, [size]);
|
|
43
|
+
} else {
|
|
44
|
+
oppositeSideEntries.push(_);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
frameSizes.sort((a, b) => a - b);
|
|
48
|
+
const smallest = frameSizes[0];
|
|
49
|
+
const secondSmallest = frameSizes[1];
|
|
50
|
+
if (smallest < thisFrameSize) {
|
|
51
|
+
const nearbyErrorFrames = sameSideEntries.filter((_) => _.frame[sizeKey] < thisFrameSize).map((_) => _.frame);
|
|
52
|
+
return new KnownError(
|
|
53
|
+
LAYOUT_ERROR.CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL,
|
|
54
|
+
// it's too complicated to calculate, happens in last example, if we get frame B, frame A is smaller
|
|
55
|
+
// attempting to resize it is very complicated
|
|
56
|
+
`Cannot close ${frame.id}, nearby affected frame/s ${readable(nearbyErrorFrames.map((_) => _.id))} are smaller than this one, we cannot calculate how to close it.`,
|
|
57
|
+
{ frame, nearbyFrames: nearbyErrorFrames, minSize }
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (thisFrameSize !== smallest) {
|
|
61
|
+
unreachable();
|
|
62
|
+
}
|
|
63
|
+
if (secondSmallest) {
|
|
64
|
+
if (secondSmallest - smallest < minSize[sizeKey]) {
|
|
65
|
+
const nearbyErrorFrames = sameSideEntries.filter((_) => frame[sizeKey] < minSize[sizeKey]).map((_) => _.frame);
|
|
66
|
+
return new KnownError(
|
|
67
|
+
LAYOUT_ERROR.CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL,
|
|
68
|
+
`Closing this frame ${frame.id} would leave the following frame/s ${readable(nearbyErrorFrames.map((_) => _.id))} below the minimum size specified.`,
|
|
69
|
+
{ frame, nearbyFrames: nearbyErrorFrames, minSize }
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const modifiedFrames = [];
|
|
74
|
+
const deletedFrames = [];
|
|
75
|
+
const moveAmount = thisFrameSize;
|
|
76
|
+
for (const entry of sameSideEntries) {
|
|
77
|
+
if (entry.frame[sizeKey] > thisFrameSize) {
|
|
78
|
+
const clone = cloneFrame(entry.frame);
|
|
79
|
+
if (side === "top" || side === "left") {
|
|
80
|
+
clone[coordKey] += moveAmount;
|
|
81
|
+
}
|
|
82
|
+
clone[sizeKey] -= moveAmount;
|
|
83
|
+
modifiedFrames.push(clone);
|
|
84
|
+
} else if (entry.frame[sizeKey] === thisFrameSize) deletedFrames.push(entry.frame);
|
|
85
|
+
else unreachable();
|
|
86
|
+
}
|
|
87
|
+
if (deletedFrames.length > 1 && !force) {
|
|
88
|
+
return new KnownError(
|
|
89
|
+
LAYOUT_ERROR.CANT_CLOSE_WITHOUT_FORCE,
|
|
90
|
+
`Cannot close in this direction, there are multiple frames in the same direction (${readable(deletedFrames.map((_) => _.id))}). Use force: true to close them.`,
|
|
91
|
+
{ frame, minSize, framesRequiredToBeDeleted: deletedFrames }
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
for (const entry of oppositeSideEntries) {
|
|
95
|
+
const clone = cloneFrame(entry.frame);
|
|
96
|
+
if (sideOpposite === "top" || sideOpposite === "left") {
|
|
97
|
+
clone[coordKey] -= moveAmount;
|
|
98
|
+
}
|
|
99
|
+
clone[sizeKey] += moveAmount;
|
|
100
|
+
modifiedFrames.push(clone);
|
|
101
|
+
}
|
|
102
|
+
return { modifiedFrames, deletedFrames };
|
|
103
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { findSafeSplitEdgeAndPosition } from "./findSafeSplitEdge.js";
|
|
2
|
+
import { frameCreate } from "./frameCreate.js";
|
|
3
|
+
import { cloneFrame } from "../helpers/cloneFrame.js";
|
|
4
|
+
import { getMarginSize, getSnapPoint } from "../settings.js";
|
|
5
|
+
import {
|
|
6
|
+
LAYOUT_ERROR
|
|
7
|
+
} from "../types/index.js";
|
|
8
|
+
import { KnownError } from "../utils/KnownError.js";
|
|
9
|
+
export function getFrameSplitInfo(frame, dir, dragPointOrPosition = "midpoint", minSize = getMarginSize(), snapAmount = getSnapPoint()) {
|
|
10
|
+
frame = cloneFrame(frame);
|
|
11
|
+
let newFrame = { ...frame };
|
|
12
|
+
const isHorz = dir === "left" || dir === "right";
|
|
13
|
+
const sizeKey = isHorz ? "width" : "height";
|
|
14
|
+
const posKey = isHorz ? "x" : "y";
|
|
15
|
+
const position = dragPointOrPosition === "midpoint" ? isHorz ? frame.x + frame.width / 2 : frame.y + frame.height / 2 : typeof dragPointOrPosition === "number" ? dragPointOrPosition : dragPointOrPosition[isHorz ? "x" : "y"];
|
|
16
|
+
const safePosition = findSafeSplitEdgeAndPosition(
|
|
17
|
+
frame,
|
|
18
|
+
dir,
|
|
19
|
+
position,
|
|
20
|
+
snapAmount,
|
|
21
|
+
minSize
|
|
22
|
+
);
|
|
23
|
+
const newSize = dir === "right" || dir === "down" ? frame[sizeKey] + frame[posKey] - safePosition.position : safePosition.position - frame[posKey];
|
|
24
|
+
if (newSize < minSize[sizeKey]) {
|
|
25
|
+
return new KnownError(
|
|
26
|
+
LAYOUT_ERROR.CANT_SPLIT_FRAME_TOO_SMALL,
|
|
27
|
+
`Can't split frame ${frame.id} in direction ${dir}, frame is too small to be split.`,
|
|
28
|
+
{ frame, newSize, minSize: minSize[sizeKey] }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
newFrame[sizeKey] = newSize;
|
|
32
|
+
frame[sizeKey] -= newSize;
|
|
33
|
+
if (dir === "right" || dir === "down") {
|
|
34
|
+
newFrame[posKey] = safePosition.position;
|
|
35
|
+
} else {
|
|
36
|
+
frame[posKey] = safePosition.position;
|
|
37
|
+
}
|
|
38
|
+
newFrame = frameCreate({ ...newFrame, id: void 0 });
|
|
39
|
+
return { splitFrame: frame, newFrame };
|
|
40
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getMaxInt } from "../settings.js";
|
|
2
|
+
export function getFrameTo(side, frame, frames) {
|
|
3
|
+
const max = getMaxInt();
|
|
4
|
+
if (side === "top" && frame.y === 0 || side === "left" && frame.y === 0 || side === "right" && frame.x + frame.width === max || side === "bottom" && frame.x + frame.height === max) return void 0;
|
|
5
|
+
let candidate;
|
|
6
|
+
let candidateDistance = Infinity;
|
|
7
|
+
const midPointX = frame.x + Math.round(frame.width / 2);
|
|
8
|
+
const midPointY = frame.y + Math.round(frame.height / 2);
|
|
9
|
+
const dir = side === "top" || side === "bottom" ? "horizontal" : "vertical";
|
|
10
|
+
const midPoint = dir === "horizontal" ? midPointX : midPointY;
|
|
11
|
+
for (const other of frames) {
|
|
12
|
+
if (frame.id === other.id) continue;
|
|
13
|
+
const isOutOfRange = dir === "horizontal" ? other.x + other.width <= frame.x || other.x >= frame.x + frame.width : other.y + other.height <= frame.y || other.y >= frame.y + frame.height;
|
|
14
|
+
if (isOutOfRange) continue;
|
|
15
|
+
const otherMidPoint = dir === "horizontal" ? other.x + Math.round(other.width / 2) : other.y + Math.round(other.height / 2);
|
|
16
|
+
const otherDist = Math.abs(midPoint - otherMidPoint);
|
|
17
|
+
switch (side) {
|
|
18
|
+
case "left":
|
|
19
|
+
if (other.x + other.width !== frame.x) continue;
|
|
20
|
+
break;
|
|
21
|
+
case "right":
|
|
22
|
+
if (other.x !== frame.x + frame.width) continue;
|
|
23
|
+
break;
|
|
24
|
+
case "top":
|
|
25
|
+
if (other.y + other.height !== frame.y) continue;
|
|
26
|
+
break;
|
|
27
|
+
case "bottom":
|
|
28
|
+
if (other.y !== frame.y + frame.height) continue;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (otherDist < candidateDistance) {
|
|
32
|
+
candidate = other;
|
|
33
|
+
candidateDistance = otherDist;
|
|
34
|
+
} else if (otherDist === candidateDistance && candidate) {
|
|
35
|
+
if (dir === "vertical") {
|
|
36
|
+
if (other.y > candidate.y) {
|
|
37
|
+
candidate = other;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (other.x > candidate.x) {
|
|
41
|
+
candidate = other;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { closeFrame } from "./closeFrame.js";
|
|
2
|
+
export { closeFrames } from "./closeFrames.js";
|
|
3
|
+
export { createSplitDecoEdge } from "./createSplitDecoEdge.js";
|
|
4
|
+
export { createSplitDecoFromDrag } from "./createSplitDecoFromDrag.js";
|
|
5
|
+
export { debugFrame } from "./debugFrame.js";
|
|
6
|
+
export { findFramesTouchingEdge } from "./findFramesTouchingEdge.js";
|
|
7
|
+
export { findSafeSplitEdgeAndPosition } from "./findSafeSplitEdge.js";
|
|
8
|
+
export { findVisualEdge } from "./findVisualEdge.js";
|
|
9
|
+
export { frameCreate } from "./frameCreate.js";
|
|
10
|
+
export { frameSplit } from "./frameSplit.js";
|
|
11
|
+
export { getCloseFrameInfo } from "./getCloseFrameInfo.js";
|
|
12
|
+
export { getFrameSplitInfo } from "./getFrameSplitInfo.js";
|
|
13
|
+
export { getFrameTo } from "./getFrameTo.js";
|
|
14
|
+
export { isPointInFrame } from "./isPointInFrame.js";
|
|
15
|
+
export { layoutAddWindow } from "./layoutAddWindow.js";
|
|
16
|
+
export { layoutCreate } from "./layoutCreate.js";
|
|
17
|
+
export { layoutRemoveWindow } from "./layoutRemoveWindow.js";
|
|
18
|
+
export { resizeFrame } from "./resizeFrame.js";
|
|
19
|
+
export { windowAddFrame } from "./windowAddFrame.js";
|
|
20
|
+
export { windowCreate } from "./windowCreate.js";
|
|
21
|
+
export { windowRemoveFrame } from "./windowRemoveFrame.js";
|
|
22
|
+
export { windowSetActiveFrame } from "./windowSetActiveFrame.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { findFramesTouchingEdge } from "./findFramesTouchingEdge.js";
|
|
2
|
+
import { clampNumber } from "../helpers/clampNumber.js";
|
|
3
|
+
import { frameToEdges } from "../helpers/frameToEdges.js";
|
|
4
|
+
import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
|
|
5
|
+
import { getResizeLimit } from "../helpers/getResizeLimit.js";
|
|
6
|
+
import { getVisualEdges } from "../helpers/getVisualEdges.js";
|
|
7
|
+
import { isWindowEdge } from "../helpers/isWindowEdge.js";
|
|
8
|
+
import { resizeByEdge } from "../helpers/resizeByEdge.js";
|
|
9
|
+
import { getMarginSize } from "../settings.js";
|
|
10
|
+
export function resizeFrame(win, frame, dir, distance, minSize = getMarginSize()) {
|
|
11
|
+
const originalDistance = distance;
|
|
12
|
+
const frameEdges = frameToEdges(frame);
|
|
13
|
+
const resizeEdges = dir === "up" ? [frameEdges.top] : dir === "down" ? [frameEdges.bottom] : dir === "vertical" ? [frameEdges.top, frameEdges.bottom] : dir === "left" ? [frameEdges.left] : dir === "right" ? [frameEdges.right] : [frameEdges.left, frameEdges.right];
|
|
14
|
+
let divideDistance = false;
|
|
15
|
+
if (resizeEdges.length === 2) {
|
|
16
|
+
divideDistance = true;
|
|
17
|
+
}
|
|
18
|
+
let ok = false;
|
|
19
|
+
const edgeDirection = getEdgeOrientation(resizeEdges[0]);
|
|
20
|
+
const margin = minSize[edgeDirection === "vertical" ? "width" : "height"];
|
|
21
|
+
let dist = distance[edgeDirection === "vertical" ? "width" : "height"];
|
|
22
|
+
if (divideDistance) {
|
|
23
|
+
dist /= 2;
|
|
24
|
+
}
|
|
25
|
+
for (const resizeEdge of resizeEdges) {
|
|
26
|
+
const _dir = dir === "horizontal" ? resizeEdge === frameEdges.left ? "left" : "right" : dir === "vertical" ? resizeEdge === frameEdges.top ? "up" : "down" : dir;
|
|
27
|
+
let frameEdge = resizeEdge;
|
|
28
|
+
const visualEdges = getVisualEdges(Object.values(win.frames), { separateByDir: true });
|
|
29
|
+
const edges = visualEdges[edgeDirection];
|
|
30
|
+
const isWinEdge = isWindowEdge(frameEdge, edgeDirection);
|
|
31
|
+
if (isWinEdge) {
|
|
32
|
+
if (edgeDirection === "horizontal") {
|
|
33
|
+
frameEdge = frameEdge === frameEdges.top ? frameEdges.bottom : frameEdges.top;
|
|
34
|
+
} else {
|
|
35
|
+
frameEdge = frameEdge === frameEdges.right ? frameEdges.left : frameEdges.right;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let foundEdge;
|
|
39
|
+
for (const edge of edges) {
|
|
40
|
+
if (edgeDirection === "horizontal") {
|
|
41
|
+
const isInRange = frameEdge.startX >= edge.startX && frameEdge.endX <= edge.endX;
|
|
42
|
+
if (isInRange && frameEdge.startY === edge.startY) {
|
|
43
|
+
foundEdge = edge;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
const isInRange = frameEdge.startY >= edge.startY && frameEdge.endY <= edge.endY;
|
|
48
|
+
if (isInRange && frameEdge.startX === edge.startX) {
|
|
49
|
+
foundEdge = edge;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!foundEdge) {
|
|
55
|
+
distance = originalDistance;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const touchingFrames = findFramesTouchingEdge(foundEdge, Object.values(win.frames))?.map((_) => _.frame);
|
|
59
|
+
const posX = foundEdge.startX + (_dir === "left" ? -dist : dist);
|
|
60
|
+
const posY = foundEdge.startY + (_dir === "up" ? -dist : dist);
|
|
61
|
+
const wantedPos = edgeDirection === "horizontal" ? posY : posX;
|
|
62
|
+
const limitInDir = getResizeLimit(foundEdge, touchingFrames, _dir, dist, margin);
|
|
63
|
+
const reverseClamp = _dir === "right" || _dir === "down";
|
|
64
|
+
const pos = reverseClamp ? clampNumber(wantedPos, -Infinity, limitInDir) : clampNumber(wantedPos, limitInDir, Infinity);
|
|
65
|
+
resizeByEdge(touchingFrames, foundEdge, _dir, pos, dist);
|
|
66
|
+
ok = true;
|
|
67
|
+
}
|
|
68
|
+
return ok;
|
|
69
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const g = {
|
|
2
|
+
SCALE: 3,
|
|
3
|
+
maxInt: 100 * 10 ** 3,
|
|
4
|
+
SNAP_PERCENTAGE_X: 0.5,
|
|
5
|
+
SNAP_PERCENTAGE_Y: 0.5,
|
|
6
|
+
snapPoint: { x: Math.round(0.5 * 10 ** 3), y: Math.round(0.5 * 10 ** 3) },
|
|
7
|
+
MARGIN_PERCENTAGE_WIDTH: 10 ** 3,
|
|
8
|
+
MARGIN_PERCENTAGE_HEIGHT: 10 ** 3,
|
|
9
|
+
marginSize: { width: 10 ** 3, height: 10 ** 3 }
|
|
10
|
+
};
|
|
11
|
+
export const globalOptions = g;
|
|
12
|
+
export function setScale(scale) {
|
|
13
|
+
const max = 100 * 10 ** scale;
|
|
14
|
+
if (!Number.isSafeInteger(max)) {
|
|
15
|
+
throw new TypeError("Scale too high. Precision will be lost!");
|
|
16
|
+
}
|
|
17
|
+
g.SCALE = scale;
|
|
18
|
+
g.maxInt = max;
|
|
19
|
+
}
|
|
20
|
+
export function getMaxInt() {
|
|
21
|
+
return g.maxInt;
|
|
22
|
+
}
|
|
23
|
+
export function setSnapPercentage(snapPercentage) {
|
|
24
|
+
if (typeof snapPercentage === "number") {
|
|
25
|
+
g.SNAP_PERCENTAGE_X = snapPercentage;
|
|
26
|
+
g.SNAP_PERCENTAGE_Y = snapPercentage;
|
|
27
|
+
} else {
|
|
28
|
+
g.SNAP_PERCENTAGE_X = snapPercentage.x;
|
|
29
|
+
g.SNAP_PERCENTAGE_Y = snapPercentage.y;
|
|
30
|
+
}
|
|
31
|
+
g.snapPoint = {
|
|
32
|
+
x: Math.round(g.SNAP_PERCENTAGE_X * 10 ** g.SCALE),
|
|
33
|
+
y: Math.round(g.SNAP_PERCENTAGE_Y * 10 ** g.SCALE)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function getSnapPoint() {
|
|
37
|
+
return g.snapPoint;
|
|
38
|
+
}
|
|
39
|
+
export function setMarginPercentage(margin) {
|
|
40
|
+
if (typeof margin === "number") {
|
|
41
|
+
g.MARGIN_PERCENTAGE_WIDTH = margin;
|
|
42
|
+
g.MARGIN_PERCENTAGE_HEIGHT = margin;
|
|
43
|
+
} else {
|
|
44
|
+
g.MARGIN_PERCENTAGE_WIDTH = margin.width;
|
|
45
|
+
g.MARGIN_PERCENTAGE_HEIGHT = margin.height;
|
|
46
|
+
}
|
|
47
|
+
g.marginSize = {
|
|
48
|
+
width: Math.round(g.MARGIN_PERCENTAGE_WIDTH * 10 ** g.SCALE),
|
|
49
|
+
height: Math.round(g.MARGIN_PERCENTAGE_HEIGHT * 10 ** g.SCALE)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function getMarginSize() {
|
|
53
|
+
return g.marginSize;
|
|
54
|
+
}
|
|
File without changes
|