javascript - jquery: slide-in and slide-out of a box whenn scrolling -
javascript - jquery: slide-in and slide-out of a box whenn scrolling -
with code #slidebox sliding in right, after page scrolled downwards 50px. have add, when box should slide out after 150px scrolling? lines "<150" conditions did't work me... give thanks you!
<script type="text/javascript"> $(function() { $(window).scroll(function(){ if ($(window).scrolltop() > 50) $('#slidebox').animate({'right':'0px'},300); else $('#slidebox').stop(true).animate({'right':'-430px'},100); }); }); </script>
update: working result:
$(function() { $(window).scroll(function(){ if($(window).scrolltop() > 50) { $('#slidebox').animate({'right': '0px'}, 300); } else $('#slidebox').stop(true).animate({'right':'-430px'},100); if($(window).scrolltop() > 500) { $('#slidebox').stop(true).animate({'right':'-430px'},100); } });
you can seek that:
$(function() { $(window).scroll(function(){ if($(window).scrolltop() > 50) { $('#slidebox').animate({'right': '0px'}, 300); } if($(window).scrolltop() > 150) { $('#slidebox').stop(true).animate({'right':'-430px'},100); } }); });
javascript jquery slide
Comments
Post a Comment