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

What is Framer? Join the Community
Return to index
Fran Pérez
Posted Mar 18 - Read on Facebook

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?


Koen Bok


Fran Pérez

That's exactly what I need. Thanks Koen :D

Min-Sang Choi

whoa, another new awesomeness.

Raphael D'Amico

Ooh! *Deletes dozens of lines of code*

Koen Bok

Time to document the context object, I guess.

Fran Pérez

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

Ale Muñoz

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…

Koen Bok

_.filter(Framer.CurrentContext.getLayers(), (l) -> l.superLayer is null)

Fran Pérez

Yep, I was doing:

for layer in Framer.CurrentContext.getLayers()
if layer.superLayer is null

Read the entire post on Facebook