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

What is Framer? Join the Community
Return to index
Callil Capuozzo
Posted May 18 - Read on Facebook

Hi all,
I'm trying to iterate through names so I can set svgs attributes without having to copy paste. But I'm running into issues understanding how to construct the loop with my limited self taught knowledge. Here is a screenshot of a very simple attempt I've made. I want to set the attributes of object0.. object1...object2 etc which are referencing a snap.path element. I always get undefined is not a function etc. if I do it this way. Or if I try to use an array construction I get maximum call stack exceeded..

help! :)

5 Comments

Phil Hughes

I think you could just do...

for obName in [object0, object1, object2]

What you are doing is actually setting a variable named obName to string, not the actual object variable.

Johannes Eckert

you could turn it around and do something like this:

for obName in [object0, object1, object2]

obName = {} # create object
obName.path = snap.path(...)
obName.transform …

you basically create the objects in a loop. and you could have an associative array ready with all the SVG coordinates to fill in, e.g. snap.path(vectorpaths[obName])

Callil Capuozzo

Phil Hughes + Johannes Eckert thanks! Your solutions helped me a lot. If anyone wants to see how I implemented this and how to start setting up a LOT more svg animations at once check out this demo http://share.framerjs.com/jj6jr63xqadc/

Johannes Eckert

you can do "for object, i in array" to get i automatically

Callil Capuozzo

Johannes Eckert sick thats awesome, definitely another one of those days where a few more concepts clicked together

Read the entire post on Facebook