Page.visual_effect :highlight

I have some code that will do the highlight, fade effect on a block of
text. It seems to work just fine until it is fired multiple times very
rapidly.

The end color matches a grey background and the start color is a yellow.

Say its run 4 times a second for 3-5 seconds. When the flashing catches
up the text will fade for the last time to the end color, then the
background will switch to a light yellow background, much fainter then
the start color. If you do the rapid fires again, after it catches up
it will fade the last time then switch to a faint shade of yellow, but
this time it will be darker yellow then the last time.

If you do the multiple fire thing a few more times, each time you stop
it will get a bit darker still.

This was happening in both Firefox and IE.

Does anyone have any experience with this?

Here is the code in my controller:

render :update do |page|
  page.visual_effect  :highlight,
                      @card.to_s,
                      :duration => 0.5,
                      :startcolor => "'#ffff00'",
                      :endcolor => "'#f1eded'"
end

This is similar to a problem I had a few weeks ago. It has to do with
the way scriptaculous does a highlight:

  1. store initial state
  2. do highlight
  3. restore initial state by setting the element’s style attribute

I bet it’s storing is a semi-highlighted state, which would be pale
yellow.

And (as I found out) step #3 plays hell on your CSS classes.

That said, I don’t know how to solve your problem, because I’ve never
done multiple highlights. You might look into scriptaculous’ Effects
Queues.

Cheers
Starr

Just wondering if you (or anyone) ever found a workaround to this
problem. Seems very much like a bug to me that you can’t highlight
multiple items too quickly without leaving all sorts of aesthetic
artifacts behind.
Right now I have a calendar view and I’m trying to get it to highlight
when you mouseover any day. This works if you move s l o w l y accross
the page, but if you start to move more quickly the highlight either
gets stuck with the highlighted color, or some color in between.

  • Thanks

Mic wrote:

I have some code that will do the highlight, fade effect on a block of
text. It seems to work just fine until it is fired multiple times very
rapidly.

The end color matches a grey background and the start color is a yellow.

Say its run 4 times a second for 3-5 seconds. When the flashing catches
up the text will fade for the last time to the end color, then the
background will switch to a light yellow background, much fainter then
the start color. If you do the rapid fires again, after it catches up
it will fade the last time then switch to a faint shade of yellow, but
this time it will be darker yellow then the last time.

If you do the multiple fire thing a few more times, each time you stop
it will get a bit darker still.

This was happening in both Firefox and IE.

Does anyone have any experience with this?

Here is the code in my controller:

render :update do |page|
  page.visual_effect  :highlight,
                      @card.to_s,
                      :duration => 0.5,
                      :startcolor => "'#ffff00'",
                      :endcolor => "'#f1eded'"
end