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.)



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, ->"one","two")
layerB.on Events.Click, ->"one","two")

I tried:

layerA.on Events.Click, ->
layerB.on Events.Click, ->"one","two")

But that didn't work.

Ofer Halevi

One option would be (substitute ~ for tab): (layer) ->
~layer.on Events.Click, ->"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