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

What is Framer? Join the Community
Return to index
Javier Eduardo Treviño
Posted Jul 31 - Read on Facebook

hello guys, I am studying the docs, kind of re-learning things, so far it's going great but I came across this example in the Objects section and I can't figure it what is it about

" The string-based notation is useful when you want to generate an object with different states in Framer.

layerA = new Layer

# Add states within a loop
for i in [1..3]
layerA.states["state#{i}"] =
y: i * 200
"

Can someone elaborate? , What are they're referring to?

3 Comments

Derek Nguyen

In that example the string-based notation is the `states["state#{i}"]` part, it's the same as doing layerA.states.state1 = ... but with string-based notation you can programmatically create states & state name

Javier Eduardo Treviño

in what situation would be this useful? I am generating 3 states but they're all identical , what for?

Derek Nguyen

The states don't have to be all identical, they can have a value being increased incrementally, like in Framer's example, the `y` position of each state of `layerA` will increase by 200 (`layerA.states.state0.y = 0, layerA.states.state1.y = 200, layerA.states.state2.y = 400,`).

Also maybe later on somewhere in your code you can match the layer's state with something else by doing `layerA.animate "state#{page.index}"` or st like that

Read the entire post on Facebook