I have this code.
$(document).ready(function() {
$(\'#box\').hide();
$(window).bind(\'scroll\', function(){
if($(this).scrollTop() > 200) {
$(
.clearQueue() worked much better than .stop()
jQuery has a stop() method - http://api.jquery.com/stop/
This article describes how to use it, seems to be exactly what you're looking for: http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup
You have to add stop function to your queue like this: $('#box').stop(true).fadeOut(300);
function stop() description: see here
Try using stop() before more animations are queued:
$(document).ready(function() {
$('#box').hide();
$(window).bind('scroll', function(){
if($(this).scrollTop() > 200) {
$("#box").stop().fadeIn(300);
}
else {
$("#box").stop().fadeOut(300);
}
});
});
See the documentation here: http://api.jquery.com/stop/
Use the stopdocs function
You simply need to call $('#box').stop(true,true).fadeIn(300);
and $('#box').stop(true,true).fadeOut(300);
respectively