Works in modern browsers and IE9+ (no CSS fade transitions in IE9).
Please view the source of this page for HTML markup, CSS and JS.
Because this is a scroll-activated script, the rate at which the function fires has the potential to be very high.
Attaching functions directly to the scroll event is usually a bad idea; Scrolling using a trackpad, scroll wheel, or just by dragging a scrollbar can easily trigger 30 events per second. Scrolling on a smartphone can trigger significantly more.
This script takes performance into consideration by using;
Did you find this useful? There are more demos and code snippets this way.