When a user scrolls down (x) pixels, I'm smoothly sliding a DIV into the viewport horizontally. If the user scrolls back up, the DIV scrolls out again. However, the sliding motion appears jerky and pauses at certain moments.
<div id="doom_o"></div>
div#doom_o {
position: fixed;
left: -300px;
z-index: -1;
height: 400px;
width: 309px;
background-image: url("../images/doom_o.png");
background-repeat: no-repeat;
}
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
setTimeout(function() {
$('#doom_o').stop().animate({left: "20%"});
}, 250);
}
else {
setTimeout(function() {
$('#doom_o').stop().animate({left: "-300px"});
}, 250);
}
});