My question is probably very easy. How to loop this function? Now, scroll event works only once. I'm looking for solution how to enable else function (smooth scroll goes from red div to blue div)
Here is js code:
var o = true; if (o === true) { $('div').scroll(function () { if(o){ $('div').animate({ scrollTop: $("#red").offset().top }, 1000); o=false; } }); } else { $('div').scroll(function () { if(o === false ){ $('div').animate({ scrollTop: $("#blue").offset().top }, 1000); o=true; document.write(o); } }); }
What I'm looking for:
After scroll to down, animation takes user to second div. When user scroll to up, animation takes user to the first div.