Contact emails
yma...@chromium.org, bo...@chromium.org
Spec
There is no spec outlining how the APIs below should work under pinch to zoom.
Summary
This change modifies the following API methods outlined in the CSSOM View Module to be relative to the layout viewport:
core/frame/Window.idl
long innerWidth;
long innerHeight;
double scrollX;
double scrollY;
double pageXOffset;
double pageYOffset;
scroll(double x, double y);
scrollTo(double x, double y);
scrollBy(double x, double y);
core/dom/Element.idl
double scrollTop;
double scrollLeft;
Motivation
Having window.scroll properties being relative to the visual viewport breaks some pages under pinch-zoom.
Consider this example:
Go to http://www.nytimes.com/
Pinch-zoom in
Android/Pixel: Two-finger zoom in gesture on the screen
Macbook: Two-finger zoom in gesture on trackpad
Click on the gear button in the top right corner to bring down the fixed-style settings menu.
Expected: The settings menu pops up right beneath the gear button
Actual: The settings menu pops up at an offset from the gear button
The plan is to have all APIs reflect the layout viewport.
Compatibility Risk
No significant compatibility risk. The way the above methods should work under pinch zoom is not specified. Firefox and safari have a different pinch to zoom model. Currently, IE follows the same model as us and this change is a step in convincing them that the above methods should be relative to the layout viewport.
Ongoing technical constraints
None.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
Link to entry on the feature dashboard
https://www.chromestatus.com/feature/4876804200333312
Requesting approval to ship?
Yes
Are you shipping the same behaviors on both desktop and mobile? Historically the visual viewport size and position have always been available on mobile browsers as innerWidth/Height, pageX/YOffset. Are you seeing any compat issues from rescinding that? That was our primary motivator, along with the strong desire to have unified behavior between desktop and mobile. Then again, that was 5 years ago so maybe the web has evolved since then J
Definitely hear you about bugs on desktop sites that never anticipated a pinch zoom before though. If the change to mobile behavior doesn’t wreck sites then changing to completely hidden sounds intriguing. I think we should have the opt-in viewport APIs available too though as a migration path for anyone who was depending on the previous behavior (I know some of the MSFT apps/sites using WinJS are currently depending on it).
Thanks,
-Matt
1. Go to http://www.nytimes.com/
2. Pinch-zoom in
o Android/Pixel: Two-finger zoom in gesture on the screen
o Macbook: Two-finger zoom in gesture on trackpad
3. Click on the gear button in the top right corner to bring down the fixed-style settings menu.
- Ad/Analytics libraries will incorrectly track what parts of the page are onscreen during pinch zoom.
- Lazy-loading scripts will think more of the page is onscreen than is actually onscreen during pinch zoom, so may download unnecessary resources.
- Zoomed websites will no longer be able to detect when a touch gesture (e.g. drag) reaches the edge of the screen (e.g. in order to scroll automatically).
- Toolbars using JS-positioning to stick to the visual viewport (screen edges) will no longer do so (but they were buggy already, see above), and will instead require scrolling to get to (in some cases, you'll have to scroll the entire length of the document before the toolbar becomes visible).
But these are all relatively minor, and I'd argue the consistency benefits outweigh these risks.