Skip to content

Commit e366c47

Browse files
committed
[cssom-view] Add segments property to visual viewport (#9237)
1 parent ffbe170 commit e366c47

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cssom-view-1/Overview.bs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,8 @@ interface VisualViewport : EventTarget {
18061806

18071807
readonly attribute double scale;
18081808

1809+
readonly attribute FrozenArray<DOMRect> segments;
1810+
18091811
attribute EventHandler onresize;
18101812
attribute EventHandler onscroll;
18111813
attribute EventHandler onscrollend;
@@ -1856,6 +1858,21 @@ The <dfn attribute for=VisualViewport>scale</dfn> attribute must run these steps
18561858
1. If there is no output device, return 1 and abort these steps.
18571859
1. Otherwise, return the <a>visual viewport</a>'s <a>scale factor</a>.
18581860

1861+
The <dfn attribute for=VisualViewport>segments</dfn> is an array of DOMRects that represent the dimensions of each existing viewport segment.
1862+
1863+
A viewport segment represents the region of the visual viewport that resides on a separate display or logical display region.
1864+
When the visual viewport spans across some number of physical features of a device, these features in turn convey a logical separation of the space available for content.
1865+
1866+
The segments attribute must run these steps:
1867+
1. If the <a>visual viewport</a>'s <a for=visualviewport>associated document</a> is not <a>fully active</a>, return 0.
1868+
2. Returns null if called from within an iframe context and abort these steps.
1869+
3. Returns null if there is only a single viewport segment and abort these steps.
1870+
4. Otherwise, return the <a>visual viewport</a>'s segments array.
1871+
1872+
Note: Based on the data returned for each viewport segment, developers will be able to infer the number of hinges available as well as the hinge orientation.
1873+
The browser window can be moved/resized such that the number of segments and/or their dimensions change.
1874+
In these cases, resize events will fire at which point authors should re-query this property, as the returned FrozenArray is just a snapshot of the current state.
1875+
18591876
<dfn attribute for=VisualViewport>onresize</dfn> is the <a>event handler IDL attribute</a> for the <a event>resize</a> event.
18601877

18611878
<dfn attribute for=VisualViewport>onscroll</dfn> is the <a>event handler IDL attribute</a> for the <a event>scroll</a> event.

0 commit comments

Comments
 (0)