11import { Size } from "types" ;
22
3- export const nodeSize = ( node : SceneNode , optimizeLayout : boolean ) : Size => {
3+ export const nodeSize = ( node : SceneNode ) : Size => {
44 if ( "layoutSizingHorizontal" in node && "layoutSizingVertical" in node ) {
55 const width =
66 node . layoutSizingHorizontal === "FILL"
@@ -19,52 +19,5 @@ export const nodeSize = (node: SceneNode, optimizeLayout: boolean): Size => {
1919 return { width, height } ;
2020 }
2121
22- const nodeAuto =
23- ( optimizeLayout && "inferredAutoLayout" in node
24- ? node . inferredAutoLayout
25- : null ) ?? node ;
26-
27- if (
28- nodeAuto &&
29- typeof nodeAuto === "object" &&
30- "layoutMode" in nodeAuto &&
31- nodeAuto . layoutMode === "NONE"
32- ) {
33- return { width : node . width , height : node . height } ;
34- }
35-
36- const hasLayout =
37- "layoutAlign" in node && node . parent && "layoutMode" in node . parent ;
38-
39- if ( ! hasLayout ) {
40- return { width : node . width , height : node . height } ;
41- }
42-
4322 return { width : node . width , height : node . height } ;
44-
45- // const isWidthFill =
46- // (parentLayoutMode === "HORIZONTAL" && nodeAuto.layoutGrow === 1) ||
47- // (parentLayoutMode === "VERTICAL" && nodeAuto.layoutAlign === "STRETCH");
48- // const isHeightFill =
49- // (parentLayoutMode === "HORIZONTAL" && nodeAuto.layoutAlign === "STRETCH") ||
50- // (parentLayoutMode === "VERTICAL" && nodeAuto.layoutGrow === 1);
51- // const modesSwapped = parentLayoutMode === "HORIZONTAL";
52- // const primaryAxisMode = modesSwapped
53- // ? "counterAxisSizingMode"
54- // : "primaryAxisSizingMode";
55- // const counterAxisMode = modesSwapped
56- // ? "primaryAxisSizingMode"
57- // : "counterAxisSizingMode";
58-
59- // return {
60- // width: isWidthFill
61- // ? "fill"
62- // : "layoutMode" in nodeAuto && nodeAuto[primaryAxisMode] === "AUTO"
63- // ? null
64- // : node.width,
65- // height: isHeightFill
66- // ? "fill"
67- // : "layoutMode" in nodeAuto && nodeAuto[counterAxisMode] === "AUTO"
68- // ? null
69- // : node.height,
7023} ;
0 commit comments