-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Editorial review: Add docs for the viewport segments api #40528
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
Editorial review: Add docs for the viewport segments api #40528
Conversation
Preview URLs (13 pages)
Flaws (11)Note! 7 documents with no flaws that don't need to be listed. 🎉 URL:
URL:
URL:
URL:
URL:
URL:
External URLs (12)URL:
URL:
URL:
URL:
URL:
URL:
URL:
(comment last updated: 2025-09-18 09:53:27) |
Hi @darktears! This PR contains the viewport segments API docs to accompany the demo you reviewed earlier in the week. Would you be OK to provide a technical review of these, too? It isn't super-urgent; I'm on vacation next week anyway, so you've got plenty of time. |
This comment was marked as resolved.
This comment was marked as resolved.
files/en-us/web/css/@media/horizontal-viewport-segments copy/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/css/@media/horizontal-viewport-segments copy/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/css/@media/horizontal-viewport-segments/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/css/@media/horizontal-viewport-segments/index.md
Outdated
Show resolved
Hide resolved
Thanks a lot for the review, @darktears; let me know if you have any other comments or concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rereview of env().
please don't hate me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env() page again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't finish.
did create a module landing page for viewport mod - #41070 assume that should go live when this does
Co-authored-by: Estelle Weyl <[email protected]>
Co-authored-by: Estelle Weyl <[email protected]>
Co-authored-by: Estelle Weyl <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments to go with the PR chrisdavidmills#13
|
||
## Instance properties | ||
|
||
_Inherits properties from its parent, {{DOMxRef("EventTarget")}}._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this accurate?
I am not seeing anything about {{DOMxRef("EventTarget")}} being the parent. I thought Window was the parent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this was a copy and paste error. I'll fix it.
The {{cssxref("@media/horizontal-viewport-segments")}} media feature detects whether the device has a specified number of viewport segments laid out horizontally, whereas the {{cssxref("@media/vertical-viewport-segments")}} media feature detects whether the device has a specified number of viewport segments laid out vertically. | ||
|
||
> [!NOTE] | ||
> Current implementations do not support more than two foldable screens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this information come from? bug / ticket #?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darktears, the engineer who implemented this stuff, told me this.
} | ||
``` | ||
|
||
Here, we are setting the outer wrapper to have a horizontal flexbox layout when the viewport segments are laid out horizontally. We then set the left container to have a width equal to the left segment width, and the right container to have a width equal to the right segment width. To calculate how much width the fold takes up in between the two, we subtract the left edge offset of the right container from the right edge offset of the left container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is identical to below. I wrote a grid example to replace this section
## Example walkthrough | ||
|
||
Let's look at these features in action in a real example. You can see our example running live at [Viewport segment API demo](https://mdn.github.io/dom-examples/viewport-segment-api/) (see the full [source code](https://github.com/mdn/dom-examples/tree/main/viewport-segment-api) also). If possible, you should view this on a foldable device. Current browser developer tools enable emulating foldable devices, but don't include emulation of the different physical segments. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an attribution
|
||
The `viewport` read-only property of the {{domxref("Window")}} interface returns a {{domxref("Viewport")}} object instance, which provides information about the current state of the device's viewport. | ||
|
||
This property can be considered the entry point to the [Viewport segments API](/en-US/docs/Web/API/Viewport_segments_API), which relies on viewport segment information returned by the {{domxref("Viewport.segments")}} property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched this to be more like other web-api-instance-property that are just placeholders for the same slug but without the /window/
|
||
### Basic `viewport` usage | ||
|
||
This snippet will loop through each segment in the viewport, and log a string to the console detailing the index number, width, and height. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above
Viewport-segments: Remote edits to PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! Just one note to remove (or add a link to bug so we can track for removal at a later time)
Co-authored-by: Estelle Weyl <[email protected]>
Description
Chrome 138 adds the Viewport Segments API, which provides a way to access the position and dimensions of logically separate viewport regions. Viewport segments are created when the viewport is split by one or more hardware features (such as a fold or a hinge between separate displays).
The API is made up of several related features:
segments
property.See also the related ChromeStatus entry: https://chromestatus.com/feature/5170498990243840
This PR adds docs for these new features. Specifically, it:
Viewport
andWindow.viewport
.@media
landing page.env()
page, and generally cleans up the structure of the page a bit.Motivation
Additional details
Related issues and pull requests