This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Weston Thayer
Posted Jun 28 - Read on Facebook

Dusting off my Framer chops -- is there any way to have a Layer automatically size itself so that width/height contains all children?


Brandon Thomas

I'm doing this iterating through the children array and essentially comparing position and size and if the next one is larger than the last set that new point to the height/width.

largestX = 0
largestY = 0
for child in @children
----if child.x + child.width > largestX
--------largestX = child.x + child.width
----if child.y + child.height > largestY
--------largestY = child.y + child.height
@width = largestX
@height = largestY

I also do this when I detect children changes so if I add or remove it will run this.

Also, hi Weston! We miss you! ❤️

Read the entire post on Facebook