[cssom-view] Consider adding a programmatic way of resetting the visual viewport scale.
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
I just came across https://bugzilla.mozilla.org/show_bug.cgi?id=1873934, which seems like a Firefox bug, but contains an interesting code snippet. Simplified below would be:
function resetZoom() {
document.head.querySelector("meta[name=viewport]")
.setAttribute("content", "width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes")
}
As hacky as it looks, the use case seems reasonable to me:
This is a map application. As such, pinching out the main screen will zoom in the map.
However, when selecting a pin, the popup appears and will open full screen. Pinching out there will zoom in the text field - so far so good.However, when closing the popup, we want to reset the user scaling to 1.0. Otherwise, some of the controls might be out of view and might not be reachable, as panning will pan the map, not the view.
Given you can pretty much achieve any scaling with the "change the meta viewport dynamically", it might be worth making the VisualViewport.scale property writable by authors?
Or if not, at least provide a way of resetting it programmatically?
thoughts? @bokand @theres-waldo @hiikezoe @smfr
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CSSOM View specification's VisualViewport.scale property and review the linked Firefox Bugzilla report and the dynamic meta viewport example. Compare the proposed writable scale property with a separate reset mechanism, then determine which behavior the specification should define. Done means reaching a clear, reviewable proposal rather than choosing an implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100