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

What is Framer? Join the Community
Return to index
Tung Pham
Posted Dec 21 - Read on Facebook

Apologize for bombarding your facebook group with more than one questions a day. But I have been trying to interate through subLayers using a loop:

for child in layer.subLayers
child.states.animationOptions =
delay: (child.index + 1)/50

However, the problem is that the loop counts in reverse! Meaning the last layer has index of 0 and this is really messing up my animation.

I tried looking for a sketch plugin that reordered all my layers in reverse but failed. I hope there is a way to do that without reordering manually.

Thank you very much!


Koen Bok

for counter, layer of layer.subLayers ...

Tung Pham

Could you please clarify what you mean? I solved this problem by doing a "trick" to my formula.

delay: (cities.subLayers.length - (child.index + 1))/30

Tung Pham

Not ideal, but it did the job. Curious to see a better way. Thanks!

Koen Bok

So for...of is a coffee script way of getting a counter _and_ item from a list. The layer.index is reverse, but the counter is not.

Read the entire post on Facebook