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

What is Framer? Join the Community
Return to index
Lukas Guschlbauer
Posted Aug 01 - Read on Facebook

Heyo!

How can I dynamically add a state via a function?

I'm currently hacking on a "Symbols"-Module and now need a way to append new states. There used to be "@.states.add" but it's deprecated. I tried to "push()" to @.states, but this doesn't work either...

This works:

@.states =
"#{stateName}":
backgroundColor: target.backgroundColor
....

- but of course this overrides the previously created states everytime I call the function...

I'd need something like:

@.states.add =
"#{stateName}":
backgroundColor: target.backgroundColor
....

6 Comments

Lukas Guschlbauer

also "@.states.#{stateName} = ..." doesn't work... :(

Chris Boy

Why you need to override the states? You can creat as many as you like

Lukas Guschlbauer

I know! :) I don't want to override, I want to append. But with a dynamic statename!

Chris Boy

Ok you can loop over the states

stateName = yourArry

For i in [0...6]
Layer[i].states =
stateName[i]:
yourPropertys

Lukas Guschlbauer

Jordan, you got an idea? :/

Jordan Robert Dobson

@.states[stateName] = backgroundColor: “red”

Read the entire post on Facebook