0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/utils/calculateAdjustment.ts
2024-04-12 18:52:19 +02:00

17 lines
468 B
TypeScript

export const calculateAdjustment = (node: SceneNode) => {
// For each child, check whether the X or Y position is less than 0 and less than the
// current adjustment.
let adjustedX = 0;
let adjustedY = 0;
if ('children' in node) {
for (const child of node.children) {
if (child.x < adjustedX) {
adjustedX = child.x;
}
if (child.y < adjustedY) {
adjustedY = child.y;
}
}
}
return [adjustedX, adjustedY];
};