javascript - Ipad iOS inconsistent scrolling: disable body scroll but allow scroll on certain elements -
on site have scrollable menus , content inside fixed page. upon loading page these elements scroll without issue. when body/html elements grabbed/focused on page bounces around , scrollable elements become unscrollable. body/html automatically focused on. behaviour can fixed clicking within scrollable elements thereby adjusting focus.
i'm wondering if there's way check element active/grabbed/focused/whatever , if it's body/html changing content.
i found solution disabling scrolling on elements preventdefault , allowing on elements stoppropagation
i'm using sizzle (jquery's selector engine) select dom elements. can replace $ selectors standard js selection (document.getelementbyid etc.), i'd highly recommend using sizzle if don't use jquery.
prevent scroll on elements:
document.addeventlistener('touchmove', function(e){e.preventdefault()}, false); $('body')[0].addeventlistener('touchmove', function(e){e.preventdefault()}, false); allow scroll elements:
$('#scrollable_div')[0].addeventlistener('touchmove', function(e){e.stoppropagation()}, false);
Comments
Post a Comment