DevicePosture
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
DevicePosture は端末形態 API のインターフェイスで、この端末の形態、すなわちビューポートが平らなのか、折り曲げられている状態なのかを表します。
インスタンスプロパティ
親である EventTarget から継承したプロパティがあります。
type読取専用 Experimental-
この端末の現在の形態を返します。
イベント
changeExperimental-
端末の形態が変化したときに発生します。
例
js
const postureOutput = document.getElementById("currentPosture");
function reportPostureOutput() {
// type プロパティは "continuous" または "folded" を返す
postureOutput.textContent = `端末の形態: ${navigator.devicePosture.type}`;
}
navigator.devicePosture.addEventListener("change", reportPostureOutput);
仕様書
| Specification |
|---|
| Device Posture API> # dom-deviceposture> |
ブラウザーの互換性
関連情報
- CSS
device-posture@media特性 - 端末形態 API
- Origin trial for Foldable APIs - developer.chrome.com (2024)