Skip to content

darktears/device-posture

 
 

Repository files navigation

'Device Posture API logo'

Device Posture API

Authors

Explainer

Abstract

This document specifies an API that allows web applications to request and be notified of changes of the posture of a foldable device.

Goals

Foldable devices come in many shapes and sizes. While the use cases for the ultrabooks of the past vary significantly from those of the new trend of mobile devices due to the inherent focus on screen real estate, the data in question is similar since it’s related to the angle of the fold.

The main interest in knowing the device posture is because there are interesting opportunities in the area of responsive design that enable new user experiences. With these new devices, the user can choose to consume content and browse the web even when the device is not flat, in which case the developer might want to provide a different layout for the content depending on how the device is being used. We propose a way to expose information about the posture of the device to the developer.

Proposals

New CSS media query: device-posture

We also propose a media query that would resolve to a set of fixed postures. These postures consist of a number of predefined values that each encompass a range of angles.

Among the values that the device-posture query can take are:

  • No Fold
  • Laptop
  • Tent
  • Tablet
  • Book
  • Flat

Examples

@media (device-posture: laptop) { ... }

/*for a monitor scenario*/
@media (device-posture: flat) and (orientation: portrait) { ... }

New JS object in window.navigator: devicePosture

The Navigator property of Window navigator should host device capabilities and system states.

Proposed Object

DevicePosture : EventTarget {
  readonly attribute DevicePostureType type;
  attribute EventHandler onchange;
}

enum DevicePostureType {
  "laptop",
  ...,
}

Stakeholder Feedback

No stakeholder feedback has been given at this time.

References & Acknowledgements

Many thanks for valuable feedback and advice from:

'drawing of different postures'

About

https://w3c.github.io/screen-fold/

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 67.2%
  • JavaScript 32.8%