So, this is how I'm changing the background color of a slot on hover
at the moment:
commits_for_page.each_with_index do |commit,i|
bg = i%2==0 ? gray(0.9) : white
@commits_list[i] = stack { commit_list_item commit, bg }
@commits_list[i].click { view_commit commit }
@commits_list[i].hover { @commits_list[i].clear { commit_list_item
commit, green } }
@commits_list[i].leave { @commits_list[i].clear { commit_list_item
commit, bg } }
end
There were a couple things that tripped me up as I was working this out.
- The context in the hover/leave block is not the slot it is attached to
- Referencing the slot from withing the hover/leave block and calling
background() paints over the existing contents
These are both things I realized I was aware of after the fact, but
apparently it wasn't what I expected while working things out.
Just sharing to provoke some discussion about the related behaviors
here and see if anyone has any ideas about a different way to approach
things. One of the main things that feels odd to me is that I am
regenerating the entire contents of these slots on each hover/leave
event, which just seems conceptually a little wacky. It actually works
out OK in terms of performance, so all in all I'm just glad to have
figured something workable out.
--
Seth Thomas Rasmussen
http://greatseth.com