coffeescriptframerjs

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?


Solution

  • 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