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

What is Framer? Join the Community
Return to index
Richard Sellies
Posted May 09 - Read on Facebook

Hi all, I'm trying to swap between two states (Or animation) every time you click on a object. But I'm not getting the code right. Ive look everywhere and still not understanding it :/

nav.menu.states.add
menuOpenAnimation:
y: -0
menuCloseAnimation:
y: -1485

nav.menubtn.onTap (event, Layer) ->
if nav.menu.states.next("menuOpenAnimation")
else
nav.menu.states.next("menuCloseAnimation")

1 Comments

Krijn Rijshouwer

Hey Richard Sellies ,

It is pretty easy. You can already give the default Layer the properties for the closed state if you want so you won't have to make an extra state for it. In the case which I think you are looking for this will save you some code. This will also enable you to type states.next() which should not contain any parameters or all the states you would like to toggle through.

Then there is also states.switch() which lets you switch to a certain state. I made you some examples. Let me know if anything is still unclear.

States.next example → http://share.framerjs.com/txq1xqvmit0d/
States.next multiple example → http://share.framerjs.com/p2v770skik7k/
States.next parameters → http://share.framerjs.com/j179tt7atwzj/
States.switch → http://share.framerjs.com/op4gg4s4y0ne/

Read the entire post on Facebook