change elements' css immediately on scroll event

Posted by jedierikb on Stack Overflow See other posts from Stack Overflow or by jedierikb
Published on 2012-09-20T14:55:26Z Indexed on 2012/09/20 15:38 UTC
Read the original article Hit count: 229

I want to change the background color of in-viewport elements (using overflow: scroll)

So here was my first attempt: http://jsfiddle.net/2YeZG/

As you see, there is a brief flicker of the previous color before the new color is painted. Others have had similar problems.

Following the HTML5 rocks instructions, I tried to introduce requestAnimationFrame to fix this problem to no avail:

http://jsfiddle.net/RETbF/

What am I doing wrong here?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css