Reputation: 10219
Is there any way to keep this simple JQuery animation from flashing? http://jsfiddle.net/v3DVf/6/
Upvotes: 1
Views: 1022
Reputation: 4699
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
.
Upvotes: 4