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

What is Framer? Join the Community
Return to index
Paul Cotton
Posted Apr 14 - Read on Facebook

Not sure if this is an impossibility or a syntax issue, but how do I group multiple variables under one variable?

Example:
I have two layers named card1 and card2.

I want to define:
bothCards = card1, card2

So that I can use: bothCards.states.add in order to apply the same state properties and animations to each of them, without having to write it out twice.
Or bothCards.y, or bothCards.animate etc.

7 Comments

Paul Cotton

Suspect this might be solved by arrays (which I am new to), will go fight with that and see.

Mike Feldstein

you can't do it the way you want but coffeescript lets you do some neat things

http://share.framerjs.com/l5afk40r7zsh/

Shirley Man

Array is the right way to go. Take a look at the CoffeeScript Intro example (line 42) made by the Framer guys. http://cl.ly/ZuPf

Paul Cotton

Thank you everyone, I'm getting there :D

Fran Pérez

Paul Cotton

Legendary. Now I've applied the starting state to the cards as a group, and triggered the return to their original state (states.next). To make it perfect I just need to put a slight delay between them, but either way this works really well and should speed up a lot of stuff in future.

Paul Cotton

My main problem was that I was trying to trigger
card.states.next()

from outside the for card in cards statement, when I should have treated it the same way I treat Utils.delay etc

Read the entire post on Facebook