openpencil/packages/core/src/layout/derived.ts
2026-08-17 12:00:01 +03:00

14 lines
603 B
TypeScript

import type { SceneNode } from '@open-pencil/scene-graph'
export function usesDetachedDerivedLayout(child: SceneNode): boolean {
const derived = child.derivedLayout
if (!derived || child.layoutMode === 'NONE' || child.layoutGrow > 0) return false
const isRow = child.layoutMode === 'HORIZONTAL'
const widthSizing = isRow ? child.primaryAxisSizing : child.counterAxisSizing
const heightSizing = isRow ? child.counterAxisSizing : child.primaryAxisSizing
return (
(widthSizing === 'HUG' && derived.width !== undefined) ||
(heightSizing === 'HUG' && derived.height !== undefined)
)
}