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

What is Framer? Join the Community
Return to index
Jeppe Reinhold
Posted Nov 30 - Read on Facebook

Hi guys!
I can't get the Utils.globalLayers to work.

I've tried with "Utils.globalLayers = psd" but it does nothing, and I've tried with "Utils.globalLayers(psd)", but that gives an error, saying it's not a function. Have I misunderstood the usage? I'm starting my file with:
psd = Framer.Importer.load("[email protected]")

I can easily access the layers using psd.bg and so on, so the importing is working fine.

5 Comments

Koen Bok

Yes. This is one of the reasons why making the layers global isn't great. It's a technical story, but everything you expose onto the global window object "leaks" in between reloads. Together with auto refresh you will see unexpected behavior like this.

Randi Dumaguet

Try Utils.globalLayers psd

Jeppe Reinhold

nope, still gives same "not a function" error :(

Koen Bok

Hey Jeppe, what does it say when you do `print Utils.globalLayers`

To be honest, it's better to be explicit like:
`{layerA, layerB} = psd`

That way autocomplete continues to work, and you avoid things like overriding the window object which will lead to very odd bugs.

Jeppe Reinhold

Wow, okay, I found the problem. If i start by writing Utils.globalLayers = psd, and then change it to Utils.globalLayers(psd) it still refers to the old psd object, which isn't a function of course. I have to REFRESH the viewer, and then write Utils.globalLayers(psd), and then it works perfectly.

But I see what you mean by your solution, autocorrect is way better. It's very manual though, and nobody likes manual labor ;)

Read the entire post on Facebook