bokand / bokand.github.io Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Firefox, as of version 67, now implements Chromium's "minimum scale size" model for sizing the fixed viewport. That is to say:
minimum-scale
from the meta viewport tag, and 0.25.position: fixed
elements, the extents to which you can scroll if the page is overflow: hidden
, and the scroll port that governs window.scrollX/Y
movements.These changes have been landing incrementally since Firefox 65, but it should all be in place as of Firefox 67 (which is in beta as of the time of this writing).
(*) There is a remaining known inconsistency with Chromium regarding the "intrinsic minimum" scale: Firefox computes it as the larger of the scale where the content height fits the visual viewport height, and the scale where the content width fits the visual viewport width. Chromium seems to consider the width only. This is tracked in bug 1508177 and we plan to align with the Chromium behaviour here too.
Quoting from the "Fixed viewport size" section of the Web Viewports Explainer:
[In Chrome, t]he fixed viewport is sized to the minimum scale size.
...
Since Chrome's the only one that's not sizing the fixed viewport to the ICB, perhaps we should change to that.
I'm trying to understand how that would work more precisely.
It seems to me like there are two sizes we can choosen from:
IIUC, Chrome currently sizes the ICB to (1), and the fixed viewport to (2).
If we want the fixed viewport and the ICB are to have the same size, then it seems the options are:
Size both to (1)
This doesn't seem to be web compatible. On many sites, (1) is narrower (because they have a meta viewport tag with width=device-width
), (2) is wider (because the content size is wider, and they don't have a minimum scale, or have a sufficiently small minimum scale), and they use overflow-x: hidden
on the root element (see e.g. most of the sites in the webcompat issues linked to bug 1123938). Such sites currently:
overflow: hidden
on the root element. (According to this comment they "used to" ignore overflow: hidden
, but as far as I can tell they still do. I'm basing this on the fact that on this test page, which has a content size larger than the minimum scale size, Safari allows scrolling in the entire content area.)overflow: hidden
on the root element..
So, if Chrome plans to go with this option, it would either break such sites, or have to start ignoring overflow: hidden
like Safari does to avoid breaking such sites.
Size both to (2)
This doesn't seem to work, because (2) is a function of the content size, which can depend on the ICB size (e.g. consider a document element with width: 50%
), so trying to size the ICB to (2) would introduce a layout cycle.
David, could you clarify which of these options you had in mind, or perhaps something else I'm not thinking of?
The page https://theres-waldo.github.io/mozilla-testcases/bug1473699.html was tested in Safari on an iPhone simulator and the behaviour observed was that the fixed position elements were being attached to the visual viewport when we zoom out to the minimum scale. However, the explainer document states that the behaviour of fixed position elements on Safari is such that the fixed position elements are attached to the layout viewport when we zoom out to minimum-scale. Do you know if Safari has perhaps had a recent change in behaviour that hasn't been reflected in the explainer document yet?
In recent Firefox releases we have implemented additional improvements to viewport-related behaviour:
innerWidth
/innerHeight
to reflect the dimensions of the fixed viewport.With these changes, I believe we are now in alignment with Chrome on all viewport-related behaviours described in this explainer doc. Please let me know if I overlooked anything!
In Firefox 63, the handling of position:fixed elements was changed so that they're attached to the larger of the ICB or the visual viewport.
This matches the behaviour of Safari, and on most pages (namely, ones where the min-scale size = the ICB size) Chrome.
Filing this issue to track updating the document to reflect this.
The explainer defines "minimum scale", but not "minimum scale size".
Based on my reading, the definition ought to be "the size of the visual viewport when zoomed out to the minimum scale". Is that accurate?
If you load https://bokand.github.io/viewporttest.html in Chromium, zoom in such that the target element is out of view, and click the target.scrollIntoView
button, the element does not get scrolled into the visual viewport.
Should it?
On a page where the fixed viewport is larger than the ICB, what should document.scrollingElement.clientWidth
return?
My experimentation seems to show that in Chrome it currently returns the ICB width.
Is this observation correct?
If so, is this the desired behaviour?
The spec says it should return "the viewport width excluding the size of a rendered scroll bar (if any)". Obviously, "viewport" in existing specs is ambiguous, but seeing as it's talking about scroll bars, I would think that, considering the implementation model described here, we'd want to use the scroll port width of one of the two scrollers, and the ICB width is neither.
I did look at this spreadsheet (linked from this section of the explainer doc) which lists the various APIs, but it's not clear to me whether it's up to date, as it talks about the "layout viewport" and not the "fixed viewport".
The explainer doc itself says that Chrome has moved to an "all fixed" model, which makes the current behaviour seem suprising.
Apologies if it's not appropriate to raise issues for something like this. But I've been looking at the different viewports and behaviours on browsers and I've noticed for the layout viewport there are potentially a couple of slightly different definitions:
Not sure if mentioning this distinction anywhere is worth it, and I could be missing something, but it does seem to be a little bit of a dual definition.
Cheers
According to the explainer, the defining role of the fixed viewport is that it is the rect that position:fixed elements attach to and get their size from.
However, it would appear that, at least in Chromium, it serves a second role as well: it defines the bounds past which you cannot scroll if the html or body element is overflow: hidden
. (I'm not sure what the appropriate name / a good name for this quantity is. In Firefox codebase terminology it would be the "scroll port" of the root scrollable element.)
A few questions:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.