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

What is Framer? Join the Community
Return to index
Kevin Gutowski
Posted May 14 - Read on Facebook

I have an object with multiple states however I want the animation time and delay for each of these states to be different. Is there a way to do this? Usually I specify the state switching options with states.animationOptions but this only controls all the switches. (I want to do something like in the photo but it doesn't work).

17 Comments

Jordan Robert Dobson

Look at events.

You can know when you're going to change state.

Then apply the animationOptions you want just in time.

Something like

SettingsIcon.on Events.WillChangeState, (toState) ->
If toState is "unfade"
SettingsIcon.states.animationOptions = {...}

The syntax there might not be exactly right so make sure to look it up in the docs. Sorry I'm on my phone ATM.

Kevin Gutowski

Ah perfect. I forgot about willchangestate. I was trying it with click but wasn't able to change animations in time.

Jordan Robert Dobson

You could probably even grab the values out of your state object just like you have it in the photo... pretty easily.

Kevin Gutowski

"StateWillSwitch" is the syntax we were looking for. Not quite sure how I would get the values of time & delay when they are specified the way I have in the image

Jordan Robert Dobson

SettingsIcon.states["unfade"].time I think.

Jordan Robert Dobson

I'd have to look at what's inside that states Object.

Kevin Gutowski

ooo I'll have to try that out sometime. Could be handy if I just want to specify all my animation effects in states.add at once

Kevin Gutowski

How would you go about checking the object itself? I'm not too familiar with Coffeescript architecture.

Jordan Robert Dobson

That's what I was thinking. You could just use the stateWillSwitch argument it gives you and use that as the key to dive in.

Fran Pérez

Just do:

layer.states.switch "stateName", curve: "ease", delay: 1

Kevin Gutowski

oh I didn't know you could specify that right within the switch control! Nice

Jordan Robert Dobson

Me either. I learned something today Fran. Is that new?

Fran Pérez

As far as I know it has always been around :)

Jordan Robert Dobson

What... Crazy.

Jordan Robert Dobson

The docs definitely don't elude to that. Probably a power user feature. :)

Fran Pérez

Then, something for Koen to add to the docs :)

Callil Capuozzo

dang this little thing just unlocked a lot of functionality for states in my mind - very cool

Read the entire post on Facebook