@witchcraft/layout 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -217,6 +217,6 @@ export function createDebugLabeler({
217
217
  const size = showSize ? ` ${f.width}x${f.height}` : "";
218
218
  const pos = showPos ? ` ${f.x},${f.y}` : "";
219
219
  const pxSize = showPxSize ? ` ${widthPx}x${heightPx}px` : "";
220
- return `${isCollapsed}${isDocked}${size}${pos}${pxSize}`;
220
+ return `${isCollapsed}${isDocked}${pos}${size}${pxSize}`;
221
221
  };
222
222
  }
@@ -34,6 +34,7 @@ export function getFrameUndockInfo(win, frameId) {
34
34
  const adjustmentKey = frameSide === "left" ? "x" : frameSide === "top" ? "y" : frameSide === "right" ? "width" : "height";
35
35
  const secondaryAdjustmentKey = frameSide === "left" ? "width" : frameSide === "top" ? "height" : frameSide === "right" ? "x" : "y";
36
36
  const adjustmentValue = frameSide === "left" || frameSide === "top" ? 0 : maxInt;
37
+ const perpendicularSizeKey = isVertical ? "width" : "height";
37
38
  const otherChanges = otherDockedFramesToResize.map((other) => {
38
39
  if (other.docked === shrinkStartKey) {
39
40
  frameClone[posKey] += other[sizeKey];
@@ -41,10 +42,12 @@ export function getFrameUndockInfo(win, frameId) {
41
42
  } else if (other.docked === shrinkEndKey) {
42
43
  frameClone[sizeKey] -= other[sizeKey];
43
44
  }
45
+ const otherIsVertical = other.docked === "left" || other.docked === "right";
46
+ const isSameAxis = isVertical === otherIsVertical;
44
47
  return {
45
48
  ...other,
46
49
  [adjustmentKey]: adjustmentValue,
47
- [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey]
50
+ ...isSameAxis ? { [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey] } : { [perpendicularSizeKey]: maxInt }
48
51
  };
49
52
  });
50
53
  return { modified: [frameClone, ...otherChanges], created: [], deleted: [] };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -325,7 +325,7 @@ export function createDebugLabeler({
325
325
  const pos = showPos ? ` ${f.x},${f.y}` : ""
326
326
  const pxSize = showPxSize ? ` ${widthPx}x${heightPx}px` : ""
327
327
 
328
- return `${isCollapsed}${isDocked}${size}${pos}${pxSize}`
328
+ return `${isCollapsed}${isDocked}${pos}${size}${pxSize}`
329
329
  }
330
330
  }
331
331
 
@@ -78,6 +78,9 @@ export function getFrameUndockInfo(
78
78
  : "y"
79
79
 
80
80
  const adjustmentValue = frameSide === "left" || frameSide === "top" ? 0 : maxInt
81
+ // for perpendicular frames (e.g. top/bottom when undocking left/right),
82
+ // expand along the dimension perpendicular to the undock axis
83
+ const perpendicularSizeKey = isVertical ? "width" : "height" as const
81
84
  const otherChanges = otherDockedFramesToResize.map(other => {
82
85
  // shrink the ends of the undocking frame
83
86
  if (other.docked === shrinkStartKey) {
@@ -86,10 +89,13 @@ export function getFrameUndockInfo(
86
89
  } else if (other.docked === shrinkEndKey) {
87
90
  frameClone[sizeKey] -= other[sizeKey]
88
91
  }
92
+ // same-axis frames shift their position; perpendicular frames expand their dimension to fill the space
93
+ const otherIsVertical = other.docked === "left" || other.docked === "right"
94
+ const isSameAxis = isVertical === otherIsVertical
89
95
  return {
90
96
  ...other,
91
97
  [adjustmentKey]: adjustmentValue,
92
- [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey]
98
+ ...(isSameAxis ? { [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey] } : { [perpendicularSizeKey]: maxInt })
93
99
  }
94
100
  })
95
101