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

What is Framer? Join the Community
Return to index
Rory Smyth
Posted Sep 21 - Read on Facebook

I'm looking to break out a lot of components from my Framer files into reusable elements. In doing so, I've created a lot of dynamic elements. Layer creation being nested inside a class somewhere.

This means though that I can't select layers directly with the name I assigned to them in the loops. I give them a dynamic name value which obviously isn't the actual variable name so Framer won't pick up on it.

How do people go about handling this? I could use the layerByName method, but I'd rather be able to select it as I would a regular layer.



Kevyn Arnott

There are a bunch of ways to solve this. Probably my favorite way to solve this is to create an object before the loop. You can call it something like "layers", so it'd be layers = {}. Then inside the loop create the layers as layers[variable] = new Layer. When you're below the loop, you reference them as layers.two or layers["two"]. So the object will effectively function as a map to the layers created in a loop. I tend to prefer this method because it doesn't require you to run a function to fetch the instance of a layer.

John Lee

Kevyn Arnott Can you help the community by posting a Framer online? Thanks :)

John Lee

Rory Smyth If you could also Share your Framer it would be really appreciated!

Rory Smyth
Read the entire post on Facebook