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

What is Framer? Join the Community
Return to index
Sarah Kranz
Posted Jul 05 - Read on Facebook

Hey there - beginner level question ;) I'm currently working through "CoffeeScript for Framer" from Tessa Thornton.
In the second example, "Toggling between states", the dropdown only opens if the menu_icon gets clicked two times. Can anybody tell me why and how to make it work with one click?

7 Comments

Sarah Kranz

This is the piece of code:

Jonas Treub

What is the default state? I think you can remove either the open or close state depending on what the default state is. Right now it probably switches between default, open and close states. If you share your prototype it is easier to see what exactly is going on. Good luck!

Sarah Kranz

uh right - that would make sense! My prototype is here http://share.framerjs.com/e0s742j5l8sk/ The one I shared above is the original code from the book, which has the same problem ;)

James Morris

With Framer, every layer comes with a "default" state. The "default" state will be the properties that the layer has by default when you create the layer (with "new Layer") or from the Sketch layer when importing. Try removing the "close" state and it's properties when defining the added states, so you only have the "open" one. That means you'll have a "default" automatically and then the "open" state. Try that?

Jonas Treub

Almost right James. The open state is the default state. You can delete the open state and with the following line you make sure it start out closed, which you probably you want.

sketch.menu_content.states.switchInstant "closed"

Sarah Kranz

alrighty - that works! Thanks a lot guys <3 http://share.framerjs.com/u325wxhn9izf/

James Morris

Boom!

Read the entire post on Facebook