I have the same properties for a few elements. I assume I can write an array that will apply the same property to a number of elements? If so, how would I write that? I tried this but doesn't work...
myLayers = [layer1, layer2, layer3]myLayers.opacity = .5
Any help would be great, thanks!
You could also set one and use layer1.copy()
for layer in [l1,l2,l3] layer.opacity = .5
Either approach should work.
ah.. OK. I didn't think I need to say "for layer..." thanks!
You need to loop over each one with a For loop.
for number in [90,87,1,6] print number + 5
If you have a lot of layers sharing the same properties you can group them in sketch and access them by Group.subLayers. Sometimes restructuring isn't possible, though. For these cases you might want to target them with a common keyword using https://github.com/awt2542/Layers-for-Framer
Jordan Robert Dobson is there a way to target all the elements of a given array, except one? Example:
arr = [layerA, layerB, layerC]
for i in arr i.on Events.Click,-> #all the items get opacity = 0 except "this"
I.opacity = 0 unless layerB
is it that easy? no way! ... let me try!!! :)
i.opacity = 0 unless i is layerB
...it doens't work: http://share.framerjs.com/40tf90i6mzax/
....found the problem: "i.opacity = 0 unless @ is layerB"
Oh yeah. Gotta keep the context.
Awesome. Glad you got it.
Thanks for your help!!! :)
Andreas Wahlström This is a beautiful piece of code: https://github.com/awt2542/Find-for-Framer I might use it in my best man speech – it's that damm good!