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

What is Framer? Join the Community
Return to index
Peter Gr
Posted Dec 16 - Read on Facebook

Hey everyone! Simple question that I haven't been able to find an answer to easily -- How could I check the state of a layer? I want to do something like this:

for modal in modal_List
___modal.states.add
______on: { opacity: 1 }
______off: { opacity: 0 }

somebutton.on Events.Click, ->
___for modal in modal_list
______if modal [is "on"]
__________modal.states.switch("off")
______else
__________modal.states.switch("on")

Basically I want to be able to toggle the state of a layer by clicking a button somewhere. Thanks in advance for your help!

3 Comments

Jordan Robert Dobson

Check out the docs under states. I think it's .current() otherwise your logic is sound.

Peter Gr

Thanks Jordan - that was exactly it.

Teodoro Mylonopoulos Labella

Hi Pedro Grey, you can also use states.next function:

somebutton.on Events.Click, ->
modal.states.next("on","off")

Depend on the state you are currently, just change the order. It saves you a lot code.

Clarify that this is for a "toggle mode", if you want to control more features you'll need a flag or conditional.

Read the entire post on Facebook