-
Notifications
You must be signed in to change notification settings - Fork 707
[css-scroll-anchoring] [css-scroll-snap] What's the optimal viewing rect on the root scroller? #4393
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
Comments
IIRC Blink does use the layout viewport. I don't really see the use case for snapping to the visual viewport and using the layout viewport makes it more intuitive and simpler to reason about for web developers, IMHO. |
Erm, never mind my comment above, snapping the visual viewport makes quite a bit of sense. I think your understanding in Blink is correct and the behavior is a bit inconsistent; Blink uses the layout viewport as the optimal viewing region (at least, scroll-padding and the like is resolved against it) but it scrolls the visual viewport when snapping.
I think that'd be more intuitive, yes, but that means that zooming in and out would have to invalidate style, right? |
Percentages are not resolved during styling, only during layout... So it'd have to invalidate layout, I guess. |
Note, this came up for us in the context of scroll anchoring, which also uses the "optimal viewing region". We have scoll anchoring choose an anchor node in the visual viewport, because otherwise content in the visual viewport could actually shift even as we keep a node that's inside the layout viewport (but outside the visual viewport) anchored. |
I wonder if we want to define the "scrollport" to be the visual viewport when talking about the root scroller, or if it should remain the layout viewport (which I think is what the current definition says) and we should define another term which does use the visual viewport? |
I'd agree that snapping should be resolved against the visual viewport: the whole point is to get the thing in view. However, I suspect scroll-padding should resolve against the layout viewport: a lot of its use cases are around avoiding certain fixed-positioned content, for example, and that resolves against the layout viewport if I'm understanding things correctly. |
Proposal is to clarify that snapping is to the visual viewport, but percentage values resolve against the layout viewport. |
The CSS Working Group just discussed
The full IRC log of that discussion<heycam> Topic: What's the optimal viewing rect on the root scroller?<heycam> github: https://github.com//issues/4393 <heycam> emilio: while working through some scroll anchoring issues <heycam> ... you need to decide what rect to anchor stuff to <heycam> ... Firefox uses visual viewport, I think Blink uses layout viewport <heycam> ... but are kind of reasonable <heycam> ... but for layout viewport, need to decide the effect of padding etc. <heycam> fantasai: my proposal is to use visual viewport, but that %s on the scroll-padding reference the layout viewport <heycam> s/of padding/of scroll-padding/ <heycam> ... that's where you're likely to block out content <heycam> TabAtkins: if we snap in the visual viewport, and you bring up the keyboard, it has to move? <heycam> jensimmons: it depends <heycam> fantasai: can leave that to the UA <heycam> TabAtkins: sounds complicated, but I think that's the best route <heycam> emilio: I think it's pretty reasonable <heycam> iank_: seems like David is fine with this change <heycam> fantasai: sounds like Blink is doing that <fantasai> https://github.com//issues/4393#issuecomment-537844295 <heycam> Rossen: currently using the layout viewport, but if you're zoomed in you're not snapped at all <heycam> iank_: but sounds like David Bokand is fine to switch to the visual viewport? <heycam> s/Bokand/Bokan/ <heycam> RESOLVED: Use visual viewport for snapping and layout viewport for scroll-padding percentages. |
…choring even when visual viewport is used. r=botond Per w3c/csswg-drafts#4393. Differential Revision: https://phabricator.services.mozilla.com/D60693
…choring even when visual viewport is used. r=botond Per w3c/csswg-drafts#4393. Differential Revision: https://phabricator.services.mozilla.com/D60693 --HG-- extra : moz-landing-system : lando
…choring even when visual viewport is used. r=botond Per w3c/csswg-drafts#4393. Differential Revision: https://phabricator.services.mozilla.com/D60693 UltraBlame original commit: c18ff86c37f78df03bbf3d590bf7c55530f2a0dc
…choring even when visual viewport is used. r=botond Per w3c/csswg-drafts#4393. Differential Revision: https://phabricator.services.mozilla.com/D60693 UltraBlame original commit: c18ff86c37f78df03bbf3d590bf7c55530f2a0dc
[css-scroll-snap] Clarify scroll-padding scrollport (w3c#4393)
Note that the css-overflow spec seems clear that the scrollport is the visual viewport. I opened #4776 clarifying scroll-padding for the root scroller. |
[css-scroll-snap] Clarify scroll-padding scrollport (#4393)
…elements and scroll-padding, since that was the goal, and UAs do fiddly things with fixedpos on mobile. #4393
Adjusted the edits to be a bit more precise, resulting in the following text:
@emilio @bokand @theres-waldo @nickburris Does this seem clear and reasonable to you? |
That seems clear, thanks. I think it's also a reasonable choice. The alternative I can think of would be to calculate the offset relative to the layout viewport but apply it relative to the visual viewport, which would have the (significant) downside that the optimal viewing region could be very small or even empty at high zoom levels. |
+1 that looks good to me, thanks! |
https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region
Firefox uses the visual viewport. Blink (if my read of their code is correct) uses the layout viewport (I think?).
The spec is unclear. It says "the scrollport".
See https://bugzilla.mozilla.org/show_bug.cgi?id=1585317#c4 for context.
If it should use the visual viewport, then scroll-padding should in theory resolve against that, rather than the layout viewport... right?
cc: @tabatkins @fantasai @bokand @skobes
The text was updated successfully, but these errors were encountered: