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

What is Framer? Join the Community
Return to index
Cosmin Negoita
Posted Apr 20 - Read on Facebook

Hey guys,

I have a couple of layers created with a for loop. I'm trying to make the hovered layer to actually play an animation with "this":

layer.on Events.MouseOver, ->
layer.states.switch("hover")

However, it only works for the last created layer. Any tips?

Thanks!

6 Comments

Davey Heuser

do (layer) ->
layer.on Events.MousOver, ->

Cosmin Negoita

Hey Davey, thanks for the reply! Unfortunately it didn't work :(

Cosmin Negoita

This is my code: for i in [0...5]
layer = new Layer
x: 80 + i*250
y: 100
name: "layer" + i
borderRadius: 10

layer.states.add
default:
shadowBlur: 0
scale: 1
hover:
shadowBlur: 50
scale: 1.25

do (layer) ->
layer.on Events.MouseOver, ->
layer.states.switch("hover")

Davey Heuser
Cosmin Negoita

Yeah, really weird, cause I opened your project and then did the same thing I did with your code and it was working. Anyway thanks man!

Davey Heuser

Oh by the way, you don't really have to define a default state since the idea of states is that you can toggle between the default (how the layer is defined) and other states

Read the entire post on Facebook