Skip to main content

Frame resize

  • March 1, 2023
  • 2 replies
  • 362 views

Forum|alt.badge.img+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

William Bishop
Mironeer
Forum|alt.badge.img+4
  • Mironeer
  • 248 replies
  • March 3, 2023

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


Forum|alt.badge.img+1
  • Author
  • New Here
  • 1 reply
  • March 3, 2023

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 ?