html - Choosing how far you scroll before a jquery animate activates -
i have code
$(window).load(function () { $elem1 = $('#div1'); $elem2 = $('#div2'); var scrollstate = 'top'; $(window).scroll(function () { var scrollpos = $(window).scrolltop(); if ((scrollpos != 0) && (scrollstate === 'top')) { $elem1.stop().animate({ opacity: '1.0' }, 300); $elem2.stop().animate({ marginleft: '50px' }, 300); scrollstate = 'scrolled'; } else if ((scrollpos === 0) && (scrollstate === 'scrolled')) { $elem1.stop().animate({ opacity: '0.0' }, 300); $elem2.stop().animate({ marginleft: '0px' }, 300); scrollstate = 'top'; } }); }); //]]>
when scroll down page jquery activates start scrolling. able choose how far down page go before activates.
can't check on value of scrollpos?
if(scrollpos > x && (scrollstate === 'top')) { //activate } else { //do nothing }