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

What is Framer? Join the Community
Return to index
Yash R Gupta
Posted May 24 - Read on Facebook

Why isn't mouseUp event affecting the layer background color in this example? As soon as the mouse button is depressed, the color should change but it doesn't seem to.


Eelco Lempsink

Hi Yash, there is a small typo in your code, it says ‘background’ instead of ‘backgroundColor’. Here’s a fixed version:

There are two other things you can improve too, first one is that you have to be aware that the ‘sel’ state is now global, so it does not keep track of a selected state *per* layer (I think that’s the intention). One way to fix that is to capture the ‘child’ in it’s own scope and include the ‘sel’ state as part of that scope. This sounds complicated, but it’s only a matter of adding ‘do (child) ->’ at the top of the loop:

The second thing that might be an improvement is to use states for the layer: You would set up the 5 non-default states and then in the mouse handlers figure out what state is in and what state in needs to move to.

Yash R Gupta

Thanks so much Eelco I was actually thinking about the individual layer states and attempting to use an array of states but couldn't get it to work.

I did use states for my first prototype which used sketch layers. But in this attempt did kind of what I would if I was working in CSS. Can you share how 'setting up 5 non default states and using the mouse handlers to change to correct state' is better than 'setting up 5 non default colors and using the mouse handlers to change to correct color'?
Again, I really appreciate you catching my typo and suggesting the improvements!

Read the entire post on Facebook