javascript - In Safari on iPad is there a way to stop the page rubber banding BUT still allow overflows too scroll? -
there's lot of snippets stop rubber-banding on ipad, 1 below:
document.body.addeventlistener('touchmove',function(event){ event.preventdefault(); },false);
however has unwanted effect of preventing divs overflows on them scrolling too?
is there way top page (body) rubber-banding while still allowing overflowed-scrolled divs so?
the rubber-banding of entire page seems happen when user scrolling bottom or top of div. code i've written checks see if user indeed @ 1 of extremes , if prevents scrolling action happening in directions.
elem.bind("touchstart", function( e ) { xstart = e.originalevent.changedtouches[0].screenx; ystart = e.originalevent.changedtouches[0].screeny; }); elem.bind("touchmove", function( e ) { var xmovement = e.originalevent.changedtouches[0].screenx - xstart; var ymovement = e.originalevent.changedtouches[0].screeny - ystart; if( elem.scrolltop() == (elem[0].scrollheight - elem[0].clientheight) && ymovement < 0 ) { e.preventdefault(); } else if( elem.scrolltop() == 0 && ymovement > 0 ) { e.preventdefault(); } e.stoppropagation(); });
update: including working jsfiddle demo link: http://jsfiddle.net/qqhrm/1/
Comments
Post a Comment