Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 97 additions & 15 deletions css-viewport-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ spec: fenced-frames; urlPrefix: https://wicg.github.io/fenced-frame/
</pre>

<pre class=link-defaults>
spec:cssom-view; type:dfn;
text:scrolling area
spec:css2; type:dfn;
text:canvas
text:viewport
spec:webdriver2; type:dfn;
text:error
text:remote end steps
Expand Down Expand Up @@ -81,41 +86,120 @@ Issue: Various issues about this specification and related specifications
are listed in <a href="https://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Investigation_of_APIs_for_Level_of_detail#The_issues_on_existing_APIs">this report</a>.
</div>

<h2 id="the-viewport">
The viewport</h2>
<h2 id="terminology">Terminology</h2>

In CSS 2.1 a <a href="https://www.w3.org/TR/CSS21/visuren.html#viewport">viewport</a>
is a feature of a user agent for [=continuous media=] and used to
In CSS 2.1 a [=viewport=] is a feature of a user agent for [=continuous media=] and used to
establish the initial containing block for [=continuous media=].
For [=paged media=], the initial containing block is based on the page area.
The page area can be set through ''@page'' rules.

This specification introduces a way of overriding the size of the viewport
provided by the user agent (UA). Because of this, we need to introduce the
difference between the [=initial viewport=] and the [=layout viewport=].
This specification introduces a way of overriding the size of the [=viewport=]
provided by the user agent (UA). Because of this, we need to define
[=initial viewport=], [=layout viewport=] and [=visual viewport=].

<dl>
<dt><dfn>initial viewport</dfn></dt>
<dt><dfn export>initial viewport</dfn></dt>
<dd>
This refers to the viewport before any UA or author styles have
overridden the viewport given by the window or viewing area of the UA.
Note that the [=initial viewport=] size will change with the
size of the window or viewing area.</dd>
<dt><dfn>layout viewport</dfn></dt>
overridden the [=viewport=] given by the window or viewing area of the UA.

Note: The [=initial viewport=] size will change with the size of the
window or viewing area.</dd>
<dt><dfn export>layout viewport</dfn></dt>
<dd>
This is the viewport you get after processing the viewport
<code>&lt;meta&gt;</code> tag.
</dd>
<dt><dfn export>visual viewport</dfn></dt>
<dd>
This is the portion of the [=layout viewport=] that is currently visible,
obtained by result of applying scale transform to it. This transform is
applied to the [=canvas=] of the [=layout viewport=] and does not affect
its internal coordinate space. The magnitude of the scale transform is
known as the [=visual viewport=]'s <dfn export>scale factor</dfn>.

Note: The [=visual viewport=] can be smaller than the [=layout viewport=].
</dd>
</dl>

ISSUE: Define visual viewport.
Note: The scale transform of the [=visual viewport=] is often referred to as
"pinch-zoom". Conceptually, this transform changes the size of the CSS
[=reference pixel=] and changes the size of the [=layout viewport=] (inversally)
proportionally so that it does not cause reflow of the page's contents.

When the [=layout viewport=] cannot fit inside the window or
viewing area, either because the [=layout viewport=] is
larger than the [=initial viewport=] or the zoom factor
causes only parts of the [=layout viewport=] to be visible,
the UA should offer a scrolling or panning mechanism.

Note: The [=visual viewport=]'s [=scrolling area=] is the [=layout viewport=].

<style>
@keyframes lvmove {
0%, 10%, 20% { transform: translate(0, 100px); }
30%, 50%, 70% { transform: translate(0, 150px); }
80%,100% { transform: translate(0, 100px); }
}
@keyframes vvmove {
0%, 10% { transform: translate(70px, 150px); }
30%, 50% { transform: translate(70px, 250px); }
80%, 90% { transform: translate(70px, 100px); }
100% { transform: translate(70px, 150px); }
}
#lv {
transform: translate(0, 100px);
animation: lvmove linear 3s infinite;
}
#vv {
transform: translate(20px, 150px);
animation: vvmove linear 3s infinite;
}
.paused #lv {
animation-play-state: paused;
}
.paused #vv {
animation-play-state: paused;
}
</style>
<div class="example paused" id="example-vvanimation">
<p>
This animation shows an example of a zoomed in visual viewport being "panned" around (for
example, by a user performing a touch drag). The page is scaled so that the layout viewport
is larger than the visual viewport.
</p>
<p>
A scroll delta is applied to the visual viewport first. When the visual viewport is at its
extent, scroll delta will be applied to the layout viewport. This behavior is implemented by
the [=viewport/perform a scroll=] steps.
</p>
<svg width="300" height="400">
<rect width="100%" height="100%" fill="white" stroke="grey" stroke-width="3"/>
<text x="10" y="30" font-family="Sans" font-size="25" fill="grey">
Document
</text>
<g id="lv">
<rect y="2" x="2" width="296" height="200" stroke="blue" fill="none" stroke-width="4"/>
<text x="10" y="20" font-family="Sans" font-size="15" fill="blue">
Layout Viewport
</text>
</g>
<g id="vv">
<rect y="2" x="2" width="148" height="100" stroke="red" fill="none" stroke-width="4"/>
<text x="10" y="60" font-family="Sans" font-size="15" fill="red">
Visual Viewport
</text>
</g>
</svg>
<br>
<button id="vvanimationBtn">Toggle Animation</button>
<script>
document.getElementById('vvanimationBtn').onclick = () => {
document.getElementById('example-vvanimation').classList.toggle('paused');
};
</script>
</div>

It is recommended that initially the upper-left corners of the
[=layout viewport=] and the window or viewing area are aligned if the
base direction of the document is ltr. Similarly, that the upper-right
Expand Down Expand Up @@ -297,8 +381,6 @@ Issue: Specify extend-to-zoom behavior by the viewport meta tag

<h3 id="interactive-widget-section">''interactive-widget''</h3>

Issue: Move the definition of ''visual viewport'' from CSSOM-View to this spec.

The <dfn export><code>interactive-widget</code></dfn> property specifies the effect that interactive UI
widgets have on the page's viewports. It defines whether widgets overlay a given viewport or whether
the viewport is shrunken so that it remains fully visible while the widget is showing. Interactive
Expand Down
98 changes: 12 additions & 86 deletions cssom-view-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ Ignore Can I Use URL Failure: https://drafts.csswg.org/cssom-view-1/

<pre class='link-defaults'>
spec:css-ui-4; type:property; text:pointer-events
spec:css-viewport; type:dfn; text:effective zoom
spec:css-viewport; type:dfn;
text:effective zoom
text:layout viewport
text:scale factor
text:visual viewport
spec:css2; type:dfn;
text: canvas
text: viewport
spec:dom; type:dfn; text:parent element
spec:html; type:dfn;
Expand Down Expand Up @@ -130,8 +133,8 @@ A <dfn export>scrolling box</dfn> of a <a>viewport</a> or element has two <dfn>o
Note that the initial scroll position might not be aligned with the [=scrolling area origin=]
depending on the [=content-distribution properties=], see [[css-align-3#overflow-scroll-position]].

The term <dfn>scrolling area</dfn> refers to a box of a <a>viewport</a> or an element that has the following edges, depending on the
<a>viewport’s</a> or element's <a>scrolling box’s</a> <a>overflow directions</a>.
The term <dfn export>scrolling area</dfn> refers to a box of a [=viewport=] or an element that has
the following edges, depending on the [=viewport=]’s or element's [=scrolling box=]’s [=overflow directions=].

<table class="complex data">
<thead>
Expand Down Expand Up @@ -293,86 +296,9 @@ The <dfn>ending edges</dfn> of a particular set of edges of a box or element are
<dd>The top and right edges.
</dl>

The <dfn>visual viewport</dfn> is a kind of <a>viewport</a> whose <a>scrolling area</a> is another <a>viewport</a>,
called the <dfn export>layout viewport</dfn>.

In addition to scrolling, the <a>visual viewport</a> may also apply a scale transform to its <a>layout viewport</a>.
This transform is applied to the <a>canvas</a> of the <a>layout viewport</a> and does not affect its internal coordinate space.

Note: The scale transform of the visual viewport is often referred to as "pinch-zoom". Conceptually, this transform
changes the size of the CSS <a>reference pixel</a> but changes the size of the layout viewport proportionally so that it
does not cause reflow of the page's contents.

The magnitude of the scale transform is known as the <a>visual viewport</a>'s <dfn>scale factor</dfn>.

<style>
@keyframes lvmove {
0%, 10%, 20% { transform: translate(0, 100px); }
30%, 50%, 70% { transform: translate(0, 150px); }
80%,100% { transform: translate(0, 100px); }
}
@keyframes vvmove {
0%, 10% { transform: translate(70px, 150px); }
30%, 50% { transform: translate(70px, 250px); }
80%, 90% { transform: translate(70px, 100px); }
100% { transform: translate(70px, 150px); }
}
#lv {
transform: translate(0, 100px);
animation: lvmove linear 3s infinite;
}
#vv {
transform: translate(20px, 150px);
animation: vvmove linear 3s infinite;
}
.paused #lv {
animation-play-state: paused;
}
.paused #vv {
animation-play-state: paused;
}
</style>
<div class="example paused" id="example-vvanimation">
<p>
This animation shows an example of a zoomed in visual viewport being "panned" around (for
example, by a user performing a touch drag). The page is scaled so that the layout viewport
is larger than the visual viewport.
</p>
<p>
A scroll delta is applied to the visual viewport first. When the visual viewport is at its
extent, scroll delta will be applied to the layout viewport. This behavior is implemented by
the [=viewport/perform a scroll=] steps.
</p>
<svg width="300" height="400">
<rect width="100%" height="100%" fill="white" stroke="grey" stroke-width="3"/>
<text x="10" y="30" font-family="Sans" font-size="25" fill="grey">
Document
</text>
<g id="lv">
<rect y="2" x="2" width="296" height="200" stroke="blue" fill="none" stroke-width="4"/>
<text x="10" y="20" font-family="Sans" font-size="15" fill="blue">
Layout Viewport
</text>
</g>
<g id="vv">
<rect y="2" x="2" width="148" height="100" stroke="red" fill="none" stroke-width="4"/>
<text x="10" y="60" font-family="Sans" font-size="15" fill="red">
Visual Viewport
</text>
</g>
</svg>
<br>
<button id="vvanimationBtn">Toggle Animation</button>
<script>
document.getElementById('vvanimationBtn').onclick = () => {
document.getElementById('example-vvanimation').classList.toggle('paused');
};
</script>
</div>

The {{VisualViewport}} object has an <dfn for=visualviewport>associated document</dfn>, which is a {{Document}} object.
It is the <a for="/">associated document</a> of the owner {{Window}} of {{VisualViewport}}. The <a>layout viewport</a>
is the owner {{Window}}'s <a>viewport</a>.
The {{VisualViewport}} object has an <dfn>associated document</dfn>, which is a {{Document}} object.
It is the [=associated document=] of the owner {{Window}} of {{VisualViewport}}. The [=layout viewport=]
is the owner {{Window}}'s [=viewport=].

For the purpose of the requirements in this specification,
elements that have a computed value of the 'display' property
Expand Down Expand Up @@ -507,8 +433,8 @@ Note: Conceptually, the visual viewport is scrolled until it "bumps up" against
edge and then "pushes" the layout viewport by applying the scroll delta to the layout viewport.
However, the scrolls in the steps above are computed ahead of time and applied in the opposite order
so that the layout viewport is scrolled before the visual viewport. This is done for historical
reasons to ensure consistent scroll event ordering. See the <a href="#example-vvanimation">example
above</a> for a visual depiction.
reasons to ensure consistent scroll event ordering. See the
<a href="https://drafts.csswg.org/css-viewport/#example-vvanimation">example</a> for a visual depiction.

</div>

Expand Down