Ver código fonte

fix(auto-layout): update position delta.y consider padding (#834)

Louis Young 3 meses atrás
pai
commit
d8b5856f44

+ 3 - 3
packages/plugins/free-auto-layout-plugin/src/layout/position.ts

@@ -45,14 +45,14 @@ export class LayoutPosition {
 
   private updateNodePosition(params: { layoutNode: LayoutNode; step: number }): void {
     const { layoutNode, step } = params;
-    const transform = layoutNode.entity.getData(TransformData);
+    const { transform, bounds } = layoutNode.entity.transform;
     const position: PositionSchema = {
       x: layoutNode.position.x + layoutNode.offset.x,
       y: layoutNode.position.y + layoutNode.offset.y,
     };
-    const deltaX = ((position.x - transform.position.x) * step) / 100;
-    const deltaY = ((position.y - transform.bounds.height / 2 - transform.position.y) * step) / 100;
 
+    const deltaX = ((position.x - transform.position.x) * step) / 100;
+    const deltaY = ((position.y - bounds.height / 2 - bounds.y) * step) / 100;
     transform.update({
       position: {
         x: transform.position.x + deltaX,

+ 1 - 1
packages/plugins/free-auto-layout-plugin/src/layout/store.ts

@@ -101,7 +101,7 @@ export class LayoutStore {
         position: { x: bounds.center.x, y: bounds.center.y },
         offset: { x: 0, y: 0 },
         size: { width: bounds.width, height: bounds.height },
-        hasChildren: node.collapsedChildren?.length > 0,
+        hasChildren: node.blocks?.length > 0,
       };
       return layoutNode;
     });