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
______on: { opacity: 1 }
______off: { opacity: 0 }

somebutton.on Events.Click, ->
___for modal in modal_list
______if modal [is "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!


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 function:

somebutton.on Events.Click, ->"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