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

What is Framer? Join the Community
Return to index
Benjamin Den Boer
Posted Nov 10 - Read on Facebook

Quick tip: here's a way you can add a set of states to multiple layers. (I've had a few people ask me if this was possible, so figured I'd make a quick example.)

Download: http://cl.ly/YQWb

5 Comments

Amy Casillas

Benjamin, thanks for this. In your code you handle the click events for layerA and layerB the same way. Is there a way to consolidate this?

layerA.on Events.Click, ->
this.states.next("one","two")
layerB.on Events.Click, ->
this.states.next("one","two")

I tried:

layerA.on Events.Click, ->
layerB.on Events.Click, ->
this.states.next("one","two")

But that didn't work.

Ofer Halevi

One option would be (substitute ~ for tab):

Layers.map (layer) ->
~layer.on Events.Click, ->
~~layer.states.next("one", "two")

Benjamin Den Boer

Hey Amy, definitely. You could also include the click event in the loop:

Jessie Chen

Thanks! Benjamin Den Boer Is there a way to define sublayer's attributes in the parent layer's state?

Benjamin Den Boer

Hey Jingshu, you can't nest states, as in, define properties of child layers when defining the states of the parent layer. You could use the same trick for subLayers, though. (Or include them) :)

Read the entire post on Facebook