jquery - Overflow hidden and scrolling -
i'm looking create unusual scroll feature on homepage of website i'm not sure of best way tackle it.
i have full screen panel (panel 1) @ top (position:absolute, height:100%) background feature. when user on section, want overflow hidden. when user tries scroll (with mousewheel or arrow key), want page slide down (or in case, panel slide positioned absolute). i'd use cubic-bezier effect using css3. reveal panel 2. here on, overflow should visible , should allow user scroll normal. once user scrolls , hits top of panel 2, want overflow return hidden , top panel slide down.
apologies if difficult understand, i've tried explain in clearest way can think of! i've tried playing around waypoint.js, i'm sure if necessary make work. illustration might make point clearer.
demo illustration
i've found website has exact effect i'm looking for, dont know how they've created it. http://mariadelaguardia.com/
you can detect if scroll down dommousescroll
. first , second element must in absolute z-index
. second div must in overflow:hidden
. after animation finished put second div overflow:auto
var isscrolled = 0; $('body').bind('wheel', function(e){ if(e.originalevent.deltay > 0) { if(isscrolled == 0){ isscrolled = 1; $("#header").animate({ top:- $("#header").height() },1000,function(){ $("#content").css({overflow:"auto"}) isscrolled = 0; }); } } if(e.originalevent.deltay < 1) { if(isscrolled == 0){ isscrolled = 1; $("#header").animate({ top: 0 },1000,function(){ $("#content").css({overflow:"hidden"}) isscrolled = 0; }); } } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="header" style="z-index:1;background:red;position:absolute;width:100%;height:100%;left:0;top:0"> </div> <div id="content" style="overflow:hidden;z-index:0;background:blue;position:absolute;width:100%;height:100%;left:0;top:0"> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> </div>
update
i have replaced dommousescroll
wheel
. work on browser.
Comments
Post a Comment