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

What is Framer? Join the Community
Return to index
Josh Ackerman
Posted Jan 24 - Read on Facebook

Hello,
How can I call layerB.bringToFront() after layer is finished animating? This is my current, failed attempt:

button.on Events.Click, ->
# some layer animations
Utils.delay .6, ->
if not layerA.isAnimating
layerB.bringToFront()

At the moment when I click on "button", layerB instantly moves to the front, rather than waiting .6s and checking if the animation is over. I would like some layers to animate before they disappear to the back. I can post the project if the context would help.

8 Comments

Joshua Tucker

Does this work?

layerA.on Events.AnimationEnd, ->
layerB.bringToFront()

Josh Ackerman

LayerB still instantly moves to the front, even if I call that function after a 10 second delay. I can not imagine any reason why.

Jordan Robert Dobson

It appears that it's an indentation problem.

Josh Ackerman

Here is a picture of the code. The [name]IconContainer.states.next() animates a few layers. The layer "Day" is their superLayer, and its opacity fades to 0. For exaggeration I added a 10s delay till the bring to front function is called.

Jordan Robert Dobson

I'm not sure your event will ever fire.

Jordan Robert Dobson

I would remove the delay. That likely isn't doing anything but hurting debugging it.

Josh Ackerman

Your second comment inspired me to move the AnimationEnd handler above the [name]IconContainer.states.next(), and now it is working. I can not think of why this works, but thanks.

Jordan Robert Dobson

Awesome. It's a bit hard to tell how it should be structured but I think it's probably a scope issue and I think it's best to not nest events like that unless you really need it. Good to hear it's working Josh!

Read the entire post on Facebook