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

What is Framer? Join the Community
Return to index
Pete Lindsberg
Posted Oct 05 - Read on Facebook

Trying to apply the same animation to several layers on click. I'm using the following code, but it doesn't work. Any suggestion?

highlight = (layerTarget) ->
sketch.subLayersByName(layerTarget).opacity = 1

sketch.myLayer1.on Events.Click, ->
highlight ("myLayer1")

sketch.myLayer2.on Events.Click, ->
highlight ("myLayer2")

sketch.myLayer3.on Events.Click, ->
highlight ("myLayer3")

2 Comments

Andrew Nalband

Try this:

highlight = (layerTarget) ->
layerTarget.opacity = 0.5

sketch.myLayer1.on Events.Click, ->
highlight (sketch.myLayer1)

sketch.myLayer2.on Events.Click, ->
highlight (sketch.myLayer2)

sketch.myLayer3.on Events.Click, ->
highlight (sketch.myLayer3)

Andrew Nalband
Read the entire post on Facebook