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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -