@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,13 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { isEdgeParallel } from "./isEdgeParallel.js";
|
|
3
|
+
export function containsEdge(edge, limitEdge, dir) {
|
|
4
|
+
dir ??= getEdgeOrientation(edge);
|
|
5
|
+
if (!isEdgeParallel(edge, limitEdge)) return false;
|
|
6
|
+
if (dir === "horizontal") {
|
|
7
|
+
if (limitEdge.startY !== edge.startY) return false;
|
|
8
|
+
return limitEdge.startX <= edge.startX && edge.endX <= limitEdge.endX;
|
|
9
|
+
} else {
|
|
10
|
+
if (limitEdge.startX !== edge.startX) return false;
|
|
11
|
+
return limitEdge.startY <= edge.startY && edge.endY <= limitEdge.endY;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function createEdge(edge) {
|
|
2
|
+
if (edge.startX > edge.endX) {
|
|
3
|
+
const end = edge.endX;
|
|
4
|
+
edge.endX = edge.startX;
|
|
5
|
+
edge.startX = end;
|
|
6
|
+
}
|
|
7
|
+
if (edge.startY > edge.endY) {
|
|
8
|
+
const end = edge.endY;
|
|
9
|
+
edge.endY = edge.startY;
|
|
10
|
+
edge.startY = end;
|
|
11
|
+
}
|
|
12
|
+
return edge;
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { inRange } from "./inRange.js";
|
|
3
|
+
import { isEdgeParallel } from "./isEdgeParallel.js";
|
|
4
|
+
export function doEdgesOverlap(edgeA, edgeB, dir) {
|
|
5
|
+
dir ??= getEdgeOrientation(edgeA);
|
|
6
|
+
if (!isEdgeParallel(edgeA, edgeB)) return false;
|
|
7
|
+
if (dir === "horizontal") {
|
|
8
|
+
if (edgeA.startY !== edgeB.startY) return false;
|
|
9
|
+
const leftMost = edgeA.startX <= edgeB.startX ? edgeA : edgeB;
|
|
10
|
+
const rightMost = edgeB === leftMost ? edgeA : edgeB;
|
|
11
|
+
const startOverlaps = inRange(leftMost.endX, rightMost.startX, rightMost.endX);
|
|
12
|
+
const endOverlaps = inRange(rightMost.startX, leftMost.startX, leftMost.endX);
|
|
13
|
+
return startOverlaps || endOverlaps;
|
|
14
|
+
} else {
|
|
15
|
+
if (edgeA.startX !== edgeB.startX) return false;
|
|
16
|
+
const topMost = edgeA.startY <= edgeB.startY ? edgeA : edgeB;
|
|
17
|
+
const bottomMost = edgeB === topMost ? edgeA : edgeB;
|
|
18
|
+
const startOverlaps = inRange(topMost.endY, bottomMost.startY, bottomMost.endY);
|
|
19
|
+
const endOverlaps = inRange(bottomMost.startY, topMost.startY, topMost.endY);
|
|
20
|
+
return startOverlaps || endOverlaps;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { isEdgeParallel } from "./isEdgeParallel.js";
|
|
3
|
+
export function doesEdgeContinueEdge(edgeA, edgeB, dir) {
|
|
4
|
+
dir ??= getEdgeOrientation(edgeA);
|
|
5
|
+
if (!isEdgeParallel(edgeA, edgeB)) return false;
|
|
6
|
+
if (dir === "horizontal") {
|
|
7
|
+
if (edgeA.startY !== edgeB.startY) return false;
|
|
8
|
+
const leftMost = edgeA.startX <= edgeB.startX ? edgeA : edgeB;
|
|
9
|
+
const rightMost = edgeB === leftMost ? edgeA : edgeB;
|
|
10
|
+
return leftMost.endX === rightMost.startX;
|
|
11
|
+
} else {
|
|
12
|
+
if (edgeA.startX !== edgeB.startX) return false;
|
|
13
|
+
const topMost = edgeA.startY <= edgeB.startY ? edgeA : edgeB;
|
|
14
|
+
const bottomMost = edgeB === topMost ? edgeA : edgeB;
|
|
15
|
+
return topMost.endY === bottomMost.startY;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { containsEdge } from "./containsEdge.js";
|
|
2
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
3
|
+
import { isEdgeEqual } from "./isEdgeEqual.js";
|
|
4
|
+
export function findDraggableEdge(edge, edges, exact = true, edgeOrientation) {
|
|
5
|
+
edgeOrientation ??= getEdgeOrientation(edge);
|
|
6
|
+
for (const otherEdge of edges) {
|
|
7
|
+
const didFindEdge = exact ? isEdgeEqual(edge, otherEdge, edgeOrientation) : containsEdge(edge, otherEdge, edgeOrientation);
|
|
8
|
+
if (didFindEdge) {
|
|
9
|
+
return otherEdge;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { findDraggableEdge } from "./findDraggableEdge.js";
|
|
2
|
+
import { frameToEdges } from "./frameToEdges.js";
|
|
3
|
+
import { isWindowEdge } from "./isWindowEdge.js";
|
|
4
|
+
import { sideToOrientation } from "./sideToOrientation.js";
|
|
5
|
+
export function findFrameDraggableEdges(frame, edges, exact = true, sides = ["left", "right", "top", "bottom"]) {
|
|
6
|
+
const frameEdges = frameToEdges(frame);
|
|
7
|
+
const res = [];
|
|
8
|
+
for (const side of sides) {
|
|
9
|
+
const edge = frameEdges[side];
|
|
10
|
+
const edgeDirection = sideToOrientation(side);
|
|
11
|
+
const isWinEdge = isWindowEdge(edge, edgeDirection);
|
|
12
|
+
if (isWinEdge) continue;
|
|
13
|
+
const maybeEdge = findDraggableEdge(edge, edges, exact, edgeDirection);
|
|
14
|
+
if (maybeEdge) res.push({ edge: maybeEdge, side });
|
|
15
|
+
}
|
|
16
|
+
if (res.length > 0) return res;
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { frameToPoints } from "./frameToPoints.js";
|
|
2
|
+
export function frameToEdges(frame, sides) {
|
|
3
|
+
const { tl, tr, bl, br } = frameToPoints(frame);
|
|
4
|
+
const right = { startX: tr.x, startY: tr.y, endX: br.x, endY: br.y };
|
|
5
|
+
const left = { startX: tl.x, startY: tl.y, endX: bl.x, endY: bl.y };
|
|
6
|
+
const bottom = { startX: bl.x, startY: bl.y, endX: br.x, endY: br.y };
|
|
7
|
+
const top = { startX: tl.x, startY: tl.y, endX: tr.x, endY: tr.y };
|
|
8
|
+
if (sides) {
|
|
9
|
+
const res = {};
|
|
10
|
+
for (const side of sides) {
|
|
11
|
+
res[side] = side === "right" ? right : side === "left" ? left : side === "bottom" ? bottom : top;
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
right,
|
|
17
|
+
left,
|
|
18
|
+
bottom,
|
|
19
|
+
top
|
|
20
|
+
};
|
|
21
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function frameToPoints(frame) {
|
|
2
|
+
const tl = { x: frame.x, y: frame.y };
|
|
3
|
+
const tr = { x: frame.x + frame.width, y: frame.y };
|
|
4
|
+
const bl = { x: frame.x, y: frame.y + frame.height };
|
|
5
|
+
const br = { x: frame.x + frame.width, y: frame.y + frame.height };
|
|
6
|
+
return { tl, tr, bl, br };
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
export function getEdgeSharedDirection(edgeA, edgeB) {
|
|
3
|
+
const edgeDirectionA = getEdgeOrientation(edgeA);
|
|
4
|
+
const edgeDirectionB = getEdgeOrientation(edgeB);
|
|
5
|
+
if (edgeDirectionA !== edgeDirectionB) return false;
|
|
6
|
+
return edgeDirectionA;
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
3
|
+
export function getEdgeSide(frame, edge, allowNone = false) {
|
|
4
|
+
const edgeDir = getEdgeOrientation(edge);
|
|
5
|
+
if (edgeDir === "horizontal") {
|
|
6
|
+
if (edge.startY === frame.y) return "top";
|
|
7
|
+
else if (edge.startY === frame.y + frame.height) return "bottom";
|
|
8
|
+
} else if (edgeDir === "vertical") {
|
|
9
|
+
if (edge.startX === frame.x) return "left";
|
|
10
|
+
else if (edge.startX === frame.x + frame.width) return "right";
|
|
11
|
+
}
|
|
12
|
+
if (!allowNone) {
|
|
13
|
+
unreachable();
|
|
14
|
+
}
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { assertItemIn } from "./assertItemIn.js";
|
|
2
|
+
import { assertWindowHasActiveFrame } from "./assertWindowHasActiveFrame.js";
|
|
3
|
+
export function getFrameConstant(win, constant, assert = false) {
|
|
4
|
+
switch (constant) {
|
|
5
|
+
case "ACTIVE": {
|
|
6
|
+
if (assert) assertWindowHasActiveFrame(win);
|
|
7
|
+
return win.activeFrame;
|
|
8
|
+
}
|
|
9
|
+
// todo sides
|
|
10
|
+
default: {
|
|
11
|
+
if (assert) assertItemIn(win.frames, constant);
|
|
12
|
+
return constant;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { castType } from "@alanscodelog/utils";
|
|
2
|
+
import { keys } from "@alanscodelog/utils/keys";
|
|
3
|
+
import { addPointsToIntersection } from "./addPointsToIntersection.js";
|
|
4
|
+
import { edgeToPoints } from "./edgeToPoints.js";
|
|
5
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
6
|
+
import { inRange } from "./inRange.js";
|
|
7
|
+
import { getMaxInt } from "../settings.js";
|
|
8
|
+
export function getIntersections(visualEdges) {
|
|
9
|
+
const intersections = {
|
|
10
|
+
// x: {y: count}
|
|
11
|
+
};
|
|
12
|
+
for (const edge of visualEdges) {
|
|
13
|
+
addPointsToIntersection(intersections, Object.values(edgeToPoints(edge)));
|
|
14
|
+
}
|
|
15
|
+
const points = [];
|
|
16
|
+
const maxInt = getMaxInt();
|
|
17
|
+
for (const x of keys(intersections)) {
|
|
18
|
+
for (const y of keys(intersections[x])) {
|
|
19
|
+
castType(x);
|
|
20
|
+
castType(y);
|
|
21
|
+
const xInt = Number.parseInt(x, 10);
|
|
22
|
+
const yInt = Number.parseInt(y, 10);
|
|
23
|
+
const isWindowEdge = xInt === 0 || yInt === 0 || xInt === maxInt || yInt === maxInt;
|
|
24
|
+
const sharedEdges = findEdgesTouchingPoint(visualEdges, {
|
|
25
|
+
x: xInt,
|
|
26
|
+
y: yInt
|
|
27
|
+
});
|
|
28
|
+
points.push({
|
|
29
|
+
point: { x: xInt, y: yInt },
|
|
30
|
+
count: intersections[x][y],
|
|
31
|
+
sharesEdge: sharedEdges.horizontal.length > 0 || sharedEdges.vertical.length > 0,
|
|
32
|
+
sharedEdges,
|
|
33
|
+
isWindowEdge
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return points;
|
|
38
|
+
}
|
|
39
|
+
function findEdgesTouchingPoint(edges, point, {
|
|
40
|
+
firstOnly = false,
|
|
41
|
+
orientation: direction = void 0,
|
|
42
|
+
inclusive = true
|
|
43
|
+
} = {}) {
|
|
44
|
+
const edgesContainingPoint = {
|
|
45
|
+
horizontal: [],
|
|
46
|
+
vertical: []
|
|
47
|
+
};
|
|
48
|
+
for (const edge of edges) {
|
|
49
|
+
const orientation = getEdgeOrientation(edge);
|
|
50
|
+
if (orientation === "horizontal" && (!direction || direction === "horizontal")) {
|
|
51
|
+
if (edge.startY === point.y && inRange(point.x, edge.startX, edge.endX, inclusive)) {
|
|
52
|
+
edgesContainingPoint.horizontal.push(edge);
|
|
53
|
+
if (firstOnly) break;
|
|
54
|
+
}
|
|
55
|
+
} else if (!direction || direction === "vertical") {
|
|
56
|
+
if (edge.startX === point.x && inRange(point.y, edge.startY, edge.endY, inclusive)) {
|
|
57
|
+
edgesContainingPoint.vertical.push(edge);
|
|
58
|
+
if (firstOnly) break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return edgesContainingPoint;
|
|
63
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getMaxInt } from "../settings.js";
|
|
2
|
+
export function getIntersectionsCss(entries, {
|
|
3
|
+
intersectionWidth = `var(--layoutIntersectionWidth, 8px)`,
|
|
4
|
+
/** How much to shift the intersections by when it's not on a four corner intersection. Otherwise it tends to look ugly because it overlaps one of the frame edges, this shifts it away from it. */
|
|
5
|
+
shiftAmount = `var(--layoutIntersectionShiftAmount, 2px)`
|
|
6
|
+
} = {}) {
|
|
7
|
+
const unscale = getMaxInt() / 100;
|
|
8
|
+
return entries.map((entry) => {
|
|
9
|
+
const point = entry.point;
|
|
10
|
+
const css = {
|
|
11
|
+
x: `${point.x / unscale}%`,
|
|
12
|
+
y: `${point.y / unscale}%`,
|
|
13
|
+
width: intersectionWidth,
|
|
14
|
+
height: intersectionWidth,
|
|
15
|
+
translate: `translate(-50%, -50%)`
|
|
16
|
+
};
|
|
17
|
+
if (shiftAmount) {
|
|
18
|
+
const shift = getIntersectionShift(entry);
|
|
19
|
+
if (shift.includes("left")) {
|
|
20
|
+
css.x = `calc(${css.x} + ${shiftAmount})`;
|
|
21
|
+
} else if (shift.includes("right")) {
|
|
22
|
+
css.x = `calc(${css.x} - ${shiftAmount})`;
|
|
23
|
+
}
|
|
24
|
+
if (shift.includes("top")) {
|
|
25
|
+
css.y = `calc(${css.y} + ${shiftAmount})`;
|
|
26
|
+
} else if (shift.includes("bottom")) {
|
|
27
|
+
css.y = `calc(${css.y} - ${shiftAmount})`;
|
|
28
|
+
}
|
|
29
|
+
if (shift !== "") {
|
|
30
|
+
;
|
|
31
|
+
css._shifted = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return css;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function getIntersectionShift(intersection) {
|
|
38
|
+
let shift = "";
|
|
39
|
+
if (intersection.sharedEdges.horizontal.length === 1) {
|
|
40
|
+
const edge = intersection.sharedEdges.horizontal[0];
|
|
41
|
+
if (edge.endX === intersection.point.x) {
|
|
42
|
+
shift += "right";
|
|
43
|
+
} else if (edge.startX === intersection.point.x) {
|
|
44
|
+
shift += "left";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (intersection.sharedEdges.vertical.length === 1) {
|
|
48
|
+
const edge = intersection.sharedEdges.vertical[0];
|
|
49
|
+
if (edge.endY === intersection.point.y) {
|
|
50
|
+
shift += "bottom";
|
|
51
|
+
} else if (edge.startY === intersection.point.y) {
|
|
52
|
+
shift += "top";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return shift;
|
|
56
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { clampNumber } from "./clampNumber.js";
|
|
2
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
3
|
+
import { getResizeLimit } from "./getResizeLimit.js";
|
|
4
|
+
import { getMarginSize } from "../settings.js";
|
|
5
|
+
export function getMoveEdgeInfo(touchingFrames, edge, position, margin = getMarginSize(), clamp = true) {
|
|
6
|
+
const { x: posX, y: posY } = position;
|
|
7
|
+
const edgeDirection = getEdgeOrientation(edge);
|
|
8
|
+
const dir = edgeDirection === "horizontal" ? posY < edge.startY ? "up" : "down" : posX < edge.startX ? "left" : "right";
|
|
9
|
+
const edgePos = edgeDirection === "vertical" ? edge.startX : edge.startY;
|
|
10
|
+
const cursorPos = edgeDirection === "vertical" ? posX : posY;
|
|
11
|
+
const amount = Math.abs(cursorPos - edgePos);
|
|
12
|
+
if (amount === 0) {
|
|
13
|
+
return {
|
|
14
|
+
x: posX,
|
|
15
|
+
y: posY,
|
|
16
|
+
dir,
|
|
17
|
+
isPassedLimit: false,
|
|
18
|
+
pos: edgePos,
|
|
19
|
+
distance: 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const limitInDir = getResizeLimit(
|
|
23
|
+
edge,
|
|
24
|
+
touchingFrames,
|
|
25
|
+
dir,
|
|
26
|
+
amount,
|
|
27
|
+
edgeDirection === "vertical" ? margin.width : margin.height
|
|
28
|
+
);
|
|
29
|
+
const distanceToLimit = Math.abs(edgePos - limitInDir);
|
|
30
|
+
const isPassedLimit = amount > distanceToLimit;
|
|
31
|
+
const reverseClamp = dir === "right" || dir === "down";
|
|
32
|
+
const pos = clamp ? reverseClamp ? clampNumber(cursorPos, -Infinity, limitInDir) : clampNumber(cursorPos, limitInDir, Infinity) : cursorPos;
|
|
33
|
+
const distance = Math.abs(pos - edgePos);
|
|
34
|
+
return {
|
|
35
|
+
x: posX,
|
|
36
|
+
y: posY,
|
|
37
|
+
dir,
|
|
38
|
+
isPassedLimit,
|
|
39
|
+
pos,
|
|
40
|
+
distance
|
|
41
|
+
};
|
|
42
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { castType } from "@alanscodelog/utils/castType";
|
|
2
|
+
import { keys } from "@alanscodelog/utils/keys";
|
|
3
|
+
import { getMaxInt } from "../settings.js";
|
|
4
|
+
export function getResizeLimit(edge, touchingFrames, dir, amount, margin) {
|
|
5
|
+
const limits = dir === "horizontal" ? { left: -Infinity, right: Infinity } : dir === "vertical" ? { up: -Infinity, down: Infinity } : { [dir]: dir === "up" || dir === "left" ? -Infinity : Infinity };
|
|
6
|
+
if (amount === 0) {
|
|
7
|
+
throw new Error("Amount cannot be zero.");
|
|
8
|
+
}
|
|
9
|
+
castType(dir);
|
|
10
|
+
for (const frame of touchingFrames) {
|
|
11
|
+
if (dir === "vertical" || dir === "up") {
|
|
12
|
+
if (frame.y < edge.startY) {
|
|
13
|
+
limits.up = Math.max(limits[dir], frame.y);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (dir === "vertical" || dir === "down") {
|
|
17
|
+
if (frame.y >= edge.startY) {
|
|
18
|
+
limits.down = Math.min(limits[dir], frame.y + frame.height);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (dir === "horizontal" || dir === "left") {
|
|
22
|
+
if (frame.x < edge.startX) {
|
|
23
|
+
limits.left = Math.max(limits[dir], frame.x);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (dir === "horizontal" || dir === "right") {
|
|
27
|
+
if (frame.x >= edge.startX) {
|
|
28
|
+
limits.right = Math.min(limits[dir], frame.x + frame.width);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const key of keys(limits)) {
|
|
33
|
+
if (limits[key] === -Infinity) limits[key] = 0;
|
|
34
|
+
if (limits[key] === Infinity) limits[key] = getMaxInt();
|
|
35
|
+
limits[key] += dir === "left" || dir === "up" ? margin : -margin;
|
|
36
|
+
}
|
|
37
|
+
if (dir === "horizontal" || dir === "vertical") return limits;
|
|
38
|
+
return limits[dir];
|
|
39
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getMaxInt } from "../settings.js";
|
|
2
|
+
export function getShapeSquareCss(obj, pad) {
|
|
3
|
+
const unscale = getMaxInt() / 100;
|
|
4
|
+
const css = {
|
|
5
|
+
x: `${obj.x / unscale}%`,
|
|
6
|
+
y: `${obj.y / unscale}%`,
|
|
7
|
+
width: `${obj.width / unscale}%`,
|
|
8
|
+
height: `${obj.height / unscale}%`
|
|
9
|
+
};
|
|
10
|
+
if (pad) {
|
|
11
|
+
css.width = `calc(${css.width} - (${pad}*2))`;
|
|
12
|
+
css.height = `calc(${css.height} - (${pad}*2))`;
|
|
13
|
+
css.x = `calc(${css.x} + (${pad}))`;
|
|
14
|
+
css.y = `calc(${css.y} + (${pad}))`;
|
|
15
|
+
}
|
|
16
|
+
return css;
|
|
17
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function getSideTouching(frameA, frameB) {
|
|
2
|
+
if (frameA.x + frameA.width === frameB.x) return "right";
|
|
3
|
+
if (frameA.x === frameB.x + frameB.width) return "left";
|
|
4
|
+
if (frameA.y + frameA.height === frameB.y) return "bottom";
|
|
5
|
+
if (frameA.y === frameB.y + frameB.height) return "top";
|
|
6
|
+
return void 0;
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
2
|
+
import { getMaxInt } from "../settings.js";
|
|
3
|
+
export function getVisualEdgeCss(edge, {
|
|
4
|
+
translate = true,
|
|
5
|
+
edgeWidth = `var(--layoutEdgeWidth, 2px)`,
|
|
6
|
+
padLongAxis,
|
|
7
|
+
padShortAxis
|
|
8
|
+
} = {}) {
|
|
9
|
+
const dir = getEdgeOrientation(edge);
|
|
10
|
+
const unscale = getMaxInt() / 100;
|
|
11
|
+
const w = (edge.endX - edge.startX) / unscale;
|
|
12
|
+
const h = (edge.endY - edge.startY) / unscale;
|
|
13
|
+
const width = dir === "vertical" ? edgeWidth : `${w}%`;
|
|
14
|
+
const height = dir === "horizontal" ? edgeWidth : `${h}%`;
|
|
15
|
+
const x = `${edge.startX / unscale}%`;
|
|
16
|
+
const y = `${edge.startY / unscale}%`;
|
|
17
|
+
const xTranslate = dir === "vertical" ? "-50%" : "0";
|
|
18
|
+
const yTranslate = dir === "horizontal" ? "-50%" : "0";
|
|
19
|
+
const translation = translate ? `translate(${xTranslate}, ${yTranslate})` : "";
|
|
20
|
+
const css = {
|
|
21
|
+
x,
|
|
22
|
+
y,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
translate: translation
|
|
26
|
+
};
|
|
27
|
+
if (padLongAxis) {
|
|
28
|
+
const axis = dir === "vertical" ? "height" : "width";
|
|
29
|
+
const coord = dir === "vertical" ? "y" : "x";
|
|
30
|
+
css[axis] = `calc(${css[axis]} - (${padLongAxis}*2))`;
|
|
31
|
+
css[coord] = `calc(${css[coord]} + (${padLongAxis}))`;
|
|
32
|
+
}
|
|
33
|
+
if (padShortAxis) {
|
|
34
|
+
const axis = dir === "vertical" ? "width" : "height";
|
|
35
|
+
const coord = dir === "vertical" ? "x" : "y";
|
|
36
|
+
css[axis] = `calc(${css[axis]} - (${padShortAxis}*2))`;
|
|
37
|
+
css[coord] = `calc(${css[coord]} + (${padShortAxis}))`;
|
|
38
|
+
}
|
|
39
|
+
return css;
|
|
40
|
+
}
|
|
File without changes
|