You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This property exposes in JavaScript what is already exposed to
CSS via env() variables.
TAG review w3ctag/design-reviews#689.
CSSWG Approval: #9237#issuecomment-2160730855
Fixes#9237.
The <dfn attribute for=Viewport>segments</dfn> property
550
+
</h2>
551
+
552
+
The {{segments}} property is an array of {{DOMRect}} that represent the dimensions of each existing viewport segment.
553
+
Each {{DOMRect}} contains the geometry of the segment (x, y, width, height) in CSS ''<length>/px''.
554
+
555
+
Additonal details about the definition of a viewport segment can be found here: [[css-env-1#viewport-segments]].
556
+
557
+
The {{segments}} attribute must run these steps:
558
+
1. If the {{Viewport}}'s associated {{Document}} is not <a>fully active</a>, return null.
559
+
2. Returns null if there is only a single viewport segment and abort these steps.
560
+
3. Otherwise, return the {{Viewport}}'s [[css-env-1#viewport-segments|segments]] array.
561
+
562
+
<div class=non-normative>
563
+
<em>This section is not normative.</em>
564
+
565
+
The {{segments}} property represents an immutable snapshot of the device {{segments}} when the value was queried.
566
+
If the device state changes (rotation, window resize, <a spec="DEVICE-POSTURE">posture</a> change), the value previously retrieved will be invalid. Developers can listen to {{ScreenOrientation/onchange|Screen Orientation}}, {{Window/resize|Window Resize}}, or {{DevicePosture/onchange|Posture}} changes events to detect device state changes.
567
+
568
+
<div class="example">
569
+
If a viewport of 400px by 400px is split horizontally into two side-by-side segments, the {{segments}} array will have the following content:
0 commit comments