Hi guys. I'm trying to create a new Layer and make it the superLayer of every other layer in the document automatically (excluding subLayers). Any ideas on how can I loop through something like Window.layers?
That's exactly what I need. Thanks Koen :D
whoa, another new awesomeness.
Ooh! *Deletes dozens of lines of code*
Time to document the context object, I guess.
Koen Framer.CurrentContext.getLayers() is returning an array with all the layers in the document, including subLayers. Am I doing something wrong? Is there a way to get only first level layers in the same context?
I could hack it, but just wondering if there was a method :)
AFAIK, the layer hierarchy is flattened on import, so you can move layers around freely in your Sketch / Photoshop document without breaking your Framer prototype. But maybe there is a way to access the actual hierarchy outside of CurrentContext…
_.filter(Framer.CurrentContext.getLayers(), (l) -> l.superLayer is null)
Yep, I was doing:
for layer in Framer.CurrentContext.getLayers()if layer.superLayer is null