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

What is Framer? Join the Community
Return to index
Danny White
Posted Nov 14 - Read on Facebook

How could you append/prepend to an existing variable to a parameter passed in a function? In English: I have a strict naming structure for multiple properties. E.g. bananaFill, kiwiFill, bananaRadius, kiwiRadius. How can I act on both the `Fill` and `Radius` properties by just writing one `fruit` parameter in the function? See the attached images for the clearest representation of what I'm trying to do. Thanks!

3 Comments

Danny White

The 'does work' .framer file: http://share.framerjs.com/4sbyqlai00j7/

Simon Lindsay

you would need to make each fruit into an object with the properties.
var kiwi = {
fill: "green",
height: 100,
radius: 36
}

then changeFruit functions will be:

changeFruit = (fruit) ->
fruit.backgroundColor = fruit.fill
fruit.height = fruit.height + "px"
fruit.radius = fruit.radius + "px"

make sense?

Danny White

got it, thanks Simon! Just had to change the parameter name from fruit to something else to avoid a conflict with the fruit layer. I.e:

changeFruit = (pass) ->
fruit.backgroundColor = pass.fill

Chur brew!

Read the entire post on Facebook