-
Notifications
You must be signed in to change notification settings - Fork 719
[css-viewport] Help me bikeshed "layout viewport" #4819
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
Maybe @chrishtr has ideas. |
Canvas |
cc @pp-koch |
It's not the canvas; the origin of the layout viewport changes with scrolling. At some future time we'll probably spec it as the box that getBoundingClientRect is relative to, and its origin will become the scroll position. |
Viewport scroll view, or viewport scroll text? |
Since Florian called on me ... I do not understand the problem. Why isn't the layout viewport a viewport? Especially combined with pinch zoom, it is (you can zoom out until the entire layout viewport fits in the visual viewport, for instance). Also, why isn't the layout viewport used for layout? After all, it is the outermost containing block for your layout; the width: auto for the HTML element is relative to the layout viewport, and the HTML element is the basis for any CSS layout. So I'd like to understand the problem better before commenting. And a bit of history: back in 2010 I needed names for what we now call the layout and visual viewport, since I was the first one to systematically describe them in public articles. Anne van Kesteren told me that the internal names within Opera were layout and visual viewport, and I ran with them and stuck to them. (As far as I know I am responsible for the spread of these names.) |
The initial containing block (which is "stuck" at the top of the document) is the one that's used for layout. The "layout viewport" moves when you scroll, and is only used for positioning fixed-position elements. It's also not really a viewport, because as soon as you zoom in, not all of the layout viewport is visible to the user. If the page is not zoomed (zoom scale == 1) then the layout viewport is the same as the old and poorly named "client rect" used in getBoundingClientRect and friends. Actually, going forward, it's probably true that the layout viewport and the "client rect" will remain the same even under zooming. |
Good reply; however,
So while it is technically possible to distinguish between the initial containing block and the layout viewports, browsers don't actually do so in case #1, and case #2 shows that the only reason we say the layout viewport 'scrolls' is because of the current implementation of position: fixed, the definition of which is exactly why you want to change the name 'layout viewport.' And now I have managed to twirl myself into a logical loop that I can't figure my way out of. So let's leave it at stating that the two started out as one and the same. On a different level, I am unconvinced that it is a good idea to change well-known names of things. As far as I can see, either web developers will ignore the name change and continue to call it layout viewport, which will lead to confusion, or they will follow the name change but not understand that it was called layout viewport in the past, also leading to confusion. W3C has had plenty of time to standardize the viewports, but didn't, even though back in 2010-3 the browsers (and I) needed some firm guidance. Thus it left the de-facto standardization of the viewports to browser vendors (and, in a small way, me; I spent about a year mailing browser vendors to get them all to align on the JavaScript properties). I feel that it's a bit late to change the entire nomenclature. But that's just my opinion, and because of my long history with the viewports I am probably a bit defensive, and certainly very happy with the status quo. |
This is true.
I had problems following this argument :) You can prove the layout viewport scrolls by comparing getBoundingClientRect() on a position:fixed vs a position:absolute element across a scroll position change.
Do web developers really think about "layout viewport" now? They are familiar with "client" coordinates presumably, and with "initial containing block" though not necessarily with that name. But I've never seen "layout viewport" used in a non browser-implementation context.
Maybe the real question here is whether we should just call it the "client rect" because that's what it is, much as I hate the name. |
@pp-koch has been teaching it under this name for a while now, and he has a bit of an audience. A bit of googling suggests he's not alone using these words, with other sources including MDN or Jake archibald. Doesn't necessarily mean it is the dominant terminology, but it has some presence. |
Thanks, Florian. I intended to do such a search, but forgot. Let me ask another question: Are there any articles that describe the layout viewport, but call it by a different name? I don't know of any, but then I never searched for it, since I already had a name. If there is none, I feel it would be fair to say that "layout viewport" is the only current term, and that it is in fairly wide use among those few who actually discuss these matters. |
in 5.1.2. Viewport-percentage Lengths: the vw, vh, vmin, vmax units
in the viewport
ok let's see what is said about canvas.
and
and in 10.3.7. Absolutely positioned, non-replaced elements.
There is also the Visual Viewport API by @bokand The intro says:
in 3.2 The VisualViewport interface
|
FWIW, when I wrote up a viewports explainer I also used "fixed viewport" rather than layout. "Layout viewport" doesn't match the initial containing block size - at least not in Blink. The behavior (I believe this varies between browsers though, at least when I last checked years ago) is that position: fixed elements attach to "the box that is the visual viewport at minimum scale". This ensures:
The latter point in particular makes the scrolling model clearer, the "layout" viewport is a scroller inside the visual viewport scroller. Given that, consider a case like this:
In this case, the layout size is 1000px but it'd be a poor choice to make the fixed div 1000px because the user will never be able to see the whole thing in the viewport. Thus the box that contains fixed elements is the minimum-scale box rather than layout. Note also, (again, maybe Blink specific) the minimum-scale can be affected outside of the viewport meta:
The minimum scale in this case will be 0.5 and fixed elements will be pushed out to attach to the larger box. Whether that's the right behavior, I'm not sure. |
I don't think "fixed viewport" is a good name to use, because it's very easily interpreted as "a viewport that does not change". |
It is somehow a kind of "computed viewport", aka the results of things once everything has been computed in the remaining visible rendered space |
CSS Position says:
That "established by the viewport" has to change in CSS Viewport to mean what implementors currently call the "layout viewport", but "layout viewport" is a sucky name (it's not used for most layout, and it's not really a viewport).
CSS Viewport could define something like "fixed position containing block", or say that the containing block for fixed position is established by the THING, but I need a name for THING.
The text was updated successfully, but these errors were encountered: