Frame resize

  • 1 March 2023
  • 2 replies
  • 309 views

Badge +1

When I create a frame and add a shape in it I can’t resize the frame to a smaller size

 

Example :

const frame = await board.createFrame({
title: “Test”,
x: 0,
y: 0,
width: 1000,
height: 1000,
});


const shape = await board.createShape({
x: 25,
y: 25,
width: 50,
height: 50,
});
await frame.add(shape);

frame.width = 500;
frame.height = 500;
await frame.sync();

I got the following error :

“Uncaught (in promise) Error: Cannot resize the frame (XXXX) to the specified size, because one or more children would exist outside the parent frame.”


2 replies

Userlevel 6
Badge +4

Hey @Oliver Coste,

Thanks for sharing this example!

One thing to note is that when children item are added to a frame, it’s relative to the top left corner of the frame. 

If the shape you’re adding overlaps with one of the boundaries of the frame when attempting to resize, you can run into this scenario.

Have you tried creating the shape with x, y coordinates closer to the center of the frame?

Thanks,
Will

Badge +1

Adding the shape works but after I can’t resize the frame to a smaller size

 

I doesn’t need to move childs when I change the size of the frame ?

Reply