Skip to content

Add viewport segments api demo #325

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

Merged
merged 12 commits into from
Aug 7, 2025

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented Jul 23, 2025

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).

This PR adds an example to demonstrate how to use it.

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner July 23, 2025 16:06
@chrisdavidmills chrisdavidmills requested review from pepelsbey and removed request for a team July 23, 2025 16:06
@chrisdavidmills chrisdavidmills marked this pull request as draft July 23, 2025 16:06
@chrisdavidmills
Copy link
Contributor Author

@darktears, would you be able to help me test this demo? I adapted the viewport segments CSS from one of your demos, and didn't change it that much.

@darktears
Copy link

darktears commented Jul 24, 2025

The demo doesn't look quite right on my Z Fold 4. But I can see similar issues on the DevTools when I use the Device Emulation mode and pick the Z Fold 5 or the Asus Zenbook Fold. I think you can go 99% of the way with the DevTools. And my demos work, I just checked them with the Z Fold 4.

@chrisdavidmills chrisdavidmills marked this pull request as ready for review July 25, 2025 07:49
@chrisdavidmills
Copy link
Contributor Author

Thanks for the code review, @darktears! This is now ready for the MDN team to review and get merged.

@chrisdavidmills
Copy link
Contributor Author

@pepelsbey this is ready for a look, if you fancy it ;-)

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I only found an edge case with JS: when you click in between the links, the section on the right gets filled with all the content. I’d suggest narrowing down the event listener and also preventing the default behavior so that the links won’t add # to URL.

Image

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect :) Thank you!

@chrisdavidmills chrisdavidmills merged commit 20fcbce into mdn:main Aug 7, 2025
1 check passed
@chrisdavidmills chrisdavidmills deleted the viewport-segments-api branch August 7, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants