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

What is Framer? Join the Community
Return to index
Cait Charn
Posted May 03 - Read on Facebook

Is there a cleaner way to do this? To have one state, and assign layers to it?


Giovanni Caruso

Something like this...

layers = []

for i in [0..3]
layer = new Layer
width: 200
height: 200
backgroundColor: Utils.randomColor()
y: 200 * i

layers.push layer

opacity: 0

for layer, i in layers
layer.onClick ->
@.stateCycle("hide", "default")

Here the project:

Jonathan Lazarini

Array with a loop perhaps or a map :)

Mike Johnson

for the elements you want to share the state, group them up in sketch without anything else. Then you can loop over the groups children directly.

for child in sketch.groupName.children
child.states =
opacity: 1

Radek Kyselý

Or this, but I'd also go with grouping as Mike said.

George Kedenburg III

you can just make your own array, no need to do all this complicated stuff with grouping...

layersToHide = [sketch.$1, sketch.$2, etc]
for layer in layersToHide
..layer.states.hide =
....opacity: 1

Read the entire post on Facebook