Sergey Prostov
Sergey Prostov

Reputation: 25

How to iterate through all the sublayers in Framer

sorry for stupid question, i need to animate all sublayers in some particular layer. How to iterate through all the sublayers?

Upvotes: 2

Views: 3908

Answers (2)

bennewton999
bennewton999

Reputation: 61

I came across this question looking for a similar solution. I wanted to change all subLayers in a given layer, even deep nested layers. In the Docs I found descendants. Adding here in case someone is looking for a solution to iterate all nested subLayers.

for descendant in layers
    descendant.ignoreEvents

Upvotes: 0

seoh
seoh

Reputation: 353

You can iterate sublayers of a layer via for-in loop

for child in layer.subLayers
    child.animate
        properties: 
            x: Utils.randomNumber(100)
            y: Utils.randomNumber(100)

if you need an index of each sublayer, you can change loop like this

for child, i in layer.subLayers

Upvotes: 3

Related Questions