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

What is Framer? Join the Community
Return to index
Vishal Iyer
Posted Feb 03 - Read on Facebook

potential noob question, but this has me a little stumped. I'm trying to understand the implications of passing the (event, layer) parameters to an event.

In the linked example. you see the following bit of code-

for image in images
-- image.borderRadius = 6
-- image.on Events.Click, (event, layer) ->
---- currentImage = layer.copy()

In my mind, I should be able to achieve the layer copy like this

for image in images
-- image.borderRadius = 6
-- image.on Events.Click, ->
---- currentImage = image.copy()

This however doesn't work, it just copies the last image in the array. Why does that happen? And how does passing the (event, layer) parameters solve for it?

3 Comments

George Kedenburg III

in your click event use "this.copy()" instead of "image.copy()"

Vishal Iyer

Thanks George! I'm guessing because of the loop, image is always assigned the last item in the array. Does the (event, layer) parameters have any other significance? This is the first time I've seen them being used

George Kedenburg III

yeah you could use the (event, layer) params to do the same thing by using the layer that gets passed in during the event... they should do the same thing but im sure theres some weird cases where "this" and "layer" would be different

Read the entire post on Facebook