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

What is Framer? Join the Community
Return to index
John Smith
Posted Apr 27 - Read on Facebook

Question I am running a for-loop which I animate several layers y positions. I'm trying to have a function fire off once the last layer animation ends. Is this possible with coffeescript?

here the code I done so far

screenTrans = ->
for layer, index in arr
layer.animate
delay: .1 * index
properties:
opacity: index * 0
y: layer.y + 50
curve: Spring(damping: .6)

4 Comments

Brian Williams

if index >= arr.length - 1 ?

Steve Ruiz

Try 'arr[arr.length].onAnimationEnd -> etc' . Put it in the function but after your loop and it should work.

Ian McClure

I think this is because everything is an expression you can actually add the animationEnd event outside the loop and it'll apply to the last item created in the loop.
Here is an example: https://framer.cloud/fJKzU

John Smith

Thanks guys. Will give it a try.

Read the entire post on Facebook