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

What is Framer? Join the Community
Return to index
Martin Halik
Posted Feb 06 - Read on Facebook

Hello may you help me, why this doesn't work?

for all sketch layers it animates only ripples[3] layer.

for i in [1...4]
sketch["sortBy#{i}"].on Events.Click, ->
ripples[i-1].opacity = 1
ripples[i-1].scale = 0.5
ripples[i-1].animate
properties:
scale:1
opacity:0
curve: "spring(300,30,0)"
time: 0.4

2 Comments

Jonas Treub

Hi Martin! The loop overrides the i variable during each iteration. During the final iteration it gets the number 3. So inside each click event the same layer is animated. To fix it you can replace ripples[i-1] with "this" (without quotes). You can read more about the topic in our programming primer: https://framer.com/getstarted/programming/#scope

Jonas Treub

Be sure to only use "this" inside of the click event. Inside of that scope it refers to the layer that has the event.

Read the entire post on Facebook