Comments (9)
Also, is the viewport state really associated with the browsing context, as opposed to the window? That's pretty counterintuitive to me. Does the zoom state persist across navigations?
from visual-viewport.
Hey - sorry for the delay - was on vacation and missed this when catching up.
Yeah, the confusion is a result of my very basic understanding of the relevant specs.
But in the spec windows don't have a browsing context set at all.
Rereading the spec, you're right, this isn't well formed. I think what I meant was rather: "If the window is currently in a Browsing Context's WindowProxy object's [[Window]] internal slot, return the object associated with it. Otherwise, return null". Does that make sense?
what happens if a script takes a reference to a VisualViewport and then the browsing context involved gets discarded?
The intent is that if the window isn't in a document that's currently being presented in a browsing context, as in this case, the visualViewport should return null.
what happens if there is no browsing context discarding, but the document of the Window the VisualViewport comes from stops being active
Chrome returns 0 for all values in that case which I think makes sense but is unspecified. I'll fix that.
Also, is the viewport state really associated with the browsing context, as opposed to the window? That's pretty counterintuitive to me. Does the zoom state persist across navigations?
Zoom does not persist across navigations so the state is associated with a window. I think the confusion here comes from the fact that the values only make sense for a visualViewport whose window is associated with an active document (one currently being presented).
Thanks for bringing up the issues. I'll make the relevant fixes in the spec.
from visual-viewport.
Does that make sense?
Yes, it does.
the visualViewport should return null
I think you misunderstood the question. The question is what happens if script asks a Window that is in a browsing context for its VisualViewport and then after that the window stops being in a browsing context. What is the behavior of the VisualViewport the script is already holding? Note that there are two sub-cases here: either the browsing context still exists but the window in question is no longer the one the WindowProxy is referencing, or the browsing context may have gotten discarded altogether.
Chrome returns 0 for all values in that case
OK. So the VisualViewport is really attached to the Window, not the browsing context, sounds like. Would be good to make that clearer.
from visual-viewport.
The question is what happens if script asks a Window that is in a browsing context for its VisualViewport and then after that the window stops being in a browsing context.
Oops, yeah I did misunderstand. In both cases -- the window is not the one referenced by WindowProxy, or the browsing context is discarded -- the visualViewport object should return 0 for all values.
from visual-viewport.
Put up a PR, mind looking it over for correctness?
from visual-viewport.
I can do that, but probably not until I get back from vacation at the end of the month, at this point.
from visual-viewport.
No worries - I'll find someone else (or wait if I can't)
from visual-viewport.
There is one thing I'm still a bit unclear about. The algorithm specified for scale
is:
1. If the window's associated Document is not fully active, return 0 and abort these steps. 2. If there is no output device, return 1 and abort these steps. ...
What steps can trigger the outcome from step 2 ("return 1 and abort these steps") of this algorithm?
from visual-viewport.
I cargo-culted that line from the definition of devicePixelRatio so I'm not certain. My guess would be a headless mode that doesn't actually produce output?
from visual-viewport.
Related Issues (20)
- Add [Exposed] to all interfaces HOT 2
- Can't position 'relative' element just above keyboard HOT 3
- changing visual viewport dynamically HOT 2
- Should window.visualViewport be null if there's no associated browsing context? HOT 1
- Value of scale for iframes is unclear in the spec HOT 1
- Is visualViewport useful for iframes? HOT 1
- Avaibality of the Visual Viewport API in non-secure contexts HOT 4
- Is emulating `position:device-fixed` really the best use case for this API? HOT 1
- Should window.scrollTo() preserve visualViewport.offset{Left,Top}? HOT 7
- How to get the size of the visual viewport + scrollbars? HOT 2
- Isn't this API a privacy issue? HOT 11
- Should specify the order of resize event with DOMWindow's resize event HOT 13
- Should specify the order of scroll event with respect to other pending scroll event targets
- Alignment opportunity with foldable and multi-screen proposal
- have window.visualViewport.segments match the matchMedia API
- Is this spec ready to move into a main W3C working group? HOT 5
- window.visualViewport.height is not correct on Safari IOS15 HOT 4
- Safari 15 supports visual viewport but it's useless because the spec missed an important thing HOT 7
- Interactions with viewport HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from visual-viewport.