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

What is Framer? Join the Community
Return to index
Fausto Pérez
Posted Jun 23 - Read on Facebook

Hi I'd like to share a little snippet to generate layers and target them by name afterwards.

It took me a while to find out, so I thought I'd share as it might be useful to beginners like me:

# Generate layers
for i in [0...3]
Framer["card#{i+1}"] = new Layer
name: "card#{i+1}" # display names in layer list

# Then you can target specific layers
Framer.card1.y = 500


Benjamin Den Boer

Sweet, cheers for sharing Fausto Pérez. :-)

Brent Riddell

I've been using window["card" + (i+1)] ... is there any difference between 'Framer' and 'window' in this case? should I be using 'Framer' instead? :)

Fausto Pérez

Nice one Brent Riddell! I'd like to know the answer to your question too...

Aaron James

Thanks for the tip! I played around with your snippet to understand it better. Here's my snazzy example.

Ke Wang

Thanks, that's pretty helpful

Philippe Côté

I’ve been looking for this. I previously succeeded in naming but not targeting. Thank you for sharing!

Read the entire post on Facebook