Is there any way to keep this simple JQuery animation from flashing? http://jsfiddle.net/v3DVf/6/
1 Answer
It's probably because you're scrolling too fast for jQuery to calculate everything. This seems to help:
$(window).scroll(function() {
var scrollTop = $(window).scrollTop();
$('#left').stop().animate({
top: (300 - (0.5 * scrollTop))
}, 350);
$('#right').stop().animate({
top: (300 - (0.2 * scrollTop))
}, 350);
});
That's caching the scrollTop value rather than recalculating, and omitting the (true, true) from the stop function.
EDIT: Also, get rid of the #container css call, just make it position: fixed
.
-
Yep. Between using a variable and setting #container to fixed, it seems that the flashing issue is solved. Thanks! jsfiddle.net/v3DVf/10 Commented Mar 23, 2012 at 19:05
top: (300 - (1.5 * $(window).scrollTop()))
0.5 to 1.5 its better