javascript - Execute scrollTop animation on $(window).scroll with jquery -


i trying move slide once every time make scroll in page. scroll event doesn't stop , repeat event. how can make animation move next slide color scrolltop inside $(window).scroll once every time? see fiddle

and piece of code doesn't work :(

$('html, body').animate({     scrolltop: ($(next).offset().top) },500); 

my target http://www.sincedilla.com/

this need. scroll event ve prevented until animation finished , docs animation http://api.jquery.com/animate/ read callback section

$(this).bind('mousewheel', function (e) {     if (!animating) {         animating = true;         if (e.originalevent.wheeldelta < 0) {             next = $(first).next();             first = $(next);             // scroll down             $("html, body").animate({                 scrolltop: ($(next).offset().top)             }, 900, function(){                 animating = false;             });         } else {             first = $(next).prev();             next = $(first);             // scroll             $("html, body").animate({                 scrolltop: ($(first).offset().top)             }, 900,function(){                 animating = false;             });         }     }     return false; }); 

working fiddle http://jsfiddle.net/fdbh0no8/


Comments