Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mobile] Ignore overflow: hidden on body when layout is larger than the viewport #79

Open
karlcow opened this issue May 26, 2017 · 5 comments

Comments

@karlcow
Copy link
Member

karlcow commented May 26, 2017

Mozilla has an open issue about this. But it would be interesting to go the core and reasoning from the Google Chrome team. I think it is a reasonable choice and it should probably be specced if there is a precise algorithm for doing it.

Explanation:
When an overflow is applied on body or html (only?) and the design presents an area which is wider than the viewport (minus top and bottom toolbars), Chrome on mobile will ignore the overflow and makes it possible for users to scroll horizontally and vertically.

@RByers and @bokand might be able to help where in the Chromium code this is happening.

@karlcow
Copy link
Member Author

karlcow commented May 26, 2017

I see that Chromium sets a bunch of preferences for Android including SetIgnoreMainFrameOverflowHiddenQuirk. I wonder if it's related.
https://cs.chromium.org/chromium/src/content/renderer/render_view_impl.cc?rcl=b854fac00a98fe03050b5ab5984e4f07ac49c99c&l=1013

@bokand
Copy link

bokand commented May 26, 2017

Chrome on mobile will ignore the overflow and makes it possible for users to scroll horizontally and vertically.

That's not accurate, Chrome respects the overflow property on body/html. However, Chrome has two viewports: the visual and layout viewports. body/html scrolling applies to the layout viewport, so when you apply overflow: hidden to body/html, it restricts layout viewport scrolling. However, we don't want to prevent the user from panning around when they zoom in on the page. If the user zooms in, they can still scroll the visual viewport around within the layout viewport - but the layout viewport doesn't scroll.

The visual viewport is what you see on the screen for any given (pinch-)zoom level. To see the layout viewport, fully zoom out. The layout viewport is set such that it's equal in size to the visual viewport when fully zoomed out. See my demo page for a more intuitive understanding. Applying overflow:hidden will prevent scrolling the blue viewport but not the red. If your page loads at some initial scale that isn't minimal, it'll appear as though you can scroll but you're really panning the red box around.

One quirk to note: Chrome allows zooming out so that all the content width can be seen (to some limit). This means a really wide element can cause the layout viewport to be expanded (so that we can zoom out sufficiently far). You can prevent the layout viewport expansion by setting a minimum-scale in your viewport meta tag.

@RByers
Copy link
Contributor

RByers commented May 27, 2017 via email

@karlcow
Copy link
Member Author

karlcow commented May 28, 2017

thanks @bokand that's very useful information and would certainly help us to have both browsers align their behavior. For now, our mutual differences for viewport handling create quite a number of Web compatibility issues, such as #62 and this one and a couple of others which might be variations.

@karlcow
Copy link
Member Author

karlcow commented May 28, 2017

@RByers fwiht (new acronym 👹 ) For what I have tested, WebKit is mostly aligned with Blink at least on my naive tests.
http://la-grange.net/2016/12/01/viewport/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants