-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
AMP documents should have touch-action: pan-y #4820
Comments
/cc @dtapuska @tdresser @KenjiBaheux who are driving the Chrome intervention. |
Lets do it. |
@RByers to confirm, |
It does actually - disables pinch-zoom completely! But I thought AMP documents (at least the ones I've seen) always have pinch-zoom disabled due to minimum-scale=1,maximum-scale=1 viewport directives? Is that not always the case? Sorry I didn't think to ask. The right fix is to instead use |
No, that's not the case. We only require Next question: what kind of effect does |
Ok The effect on Android WebView should be identical (it's all the same code) - make any horizontal scrolls over top of the WebView just send touch events without scrolling. I don't know how composition of scrolling works when a WebView is contained inside a Java ScrollView but I can loop in the right engineers if that's a potential concern. I should admit I haven't personally tested touch-action behavior inside a WebView. |
Ok. To start with I will only do this for AMP documents that are embedded. |
/cc @RByers @cramforce @ericlindley-g This has been launched last week. |
When an AMP document is hosted in a swipable container like on Google Search, they must disable horizontal scrolling to let the container handle the touch events. They already have a
html { overflow-x: hidden!important}
rule, but that's not quite enough. If the container is using passive touch listeners (so as not to interfere with scroll performance) or pointer events it won't have any way to tell the AMP document not to scroll.How do we reproduce the issue?
With the intervention enabled you'll see the AMP document start scrolling vertically and the horizontal carousel motion become janky (touchmove throttled during an active scroll). You'll also see messages like the following in the console:
What browsers are affected?
Just with Chrome's intervention on Android for now. But Other AMP containers could have similar problems in other browsers (eg. if they wanted to use pointer events on Edge, or opt-in to passive touch listeners in Mobile Safari or Chrome).
Which AMP version is affected?
Version 1472690078859
Suggested fix
The AMP document should make it's intention to support only vertical scrolling explicit to the browser with a rule like
html {touch-action: pan-y;}
. Note that this doesn't mean the document cannot contain a sub-scroller that scrolls horizontally, just that the AMP document should not handle any horizontal scroll gestures itself. Adding this style rule in devtools fixes the issue for me.The text was updated successfully, but these errors were encountered: