OK, thanks for adding me. I'm new to FramerJS, so far I am liking it. Not very good at writing codes, though. So this may not be as trivial as I think it is.
What I want to do is target all child elements (in this example, called "sidebaritem-menu") of each object (viewitem1, viewitem2, etc.)
I imagined it would be an array, but I've been searching online for hours and cant find an example how I can solve this. Please check out the screenshot to get a better idea.
Help? Thank you and happy new year.
What happens when you `print sidebar items` inside the loop?
Teh codez!!! If you access the sublayers of the parent, it will return an array. In your case it should be something like
for item in sketch.viewitems.subLayers____item.subLayersByName("sidebaritem-menu")
Where those underscores are spaces. If you're still having trouble, share a link to your prototype and we can help you out.
I've been working on a module for simplifying this kind of work. Maybe it could help here? https://github.com/awt2542/Find-for-Framer You could try printing $find ''viewitems > viewitem >". That should give you all layers below the viewitem folders.
Hi. Sorry for the late response guys. As you know, there's new Years' Eve, celebration, family, stuffs.
Awesome, thank you for the replies. I kinda like Andreas' solution but I can probably use that when all else fails. To get a better look at my problem, you can get the source code from here:https://www.dropbox.com/sh/bb8m5t3ux1a2qul/AABPjSfoEro8N-ICRkfUKm3va?dl=0
In my example, when I print the sublayers (content, threedots), it targets them just fine. But when I assign properties to it (like opacity = 0), it doesn't respect that somehow.
I am first, a designer. So my coding is not the best. Please be patient with me. Thank you again.
As you can see from the printing, subLayers returns an array. That's basically a list of layers inside brackets . Now, you can't change visibility on the array. That's a property of the layer object. That's why submenu.opacity won't work. Try looping through the submenu array instead and set opacity on each layer in it, separately.
Wow, that actually works. Thank you very much, Andreas. Have a great 2016!
Great! Glad I could help!