Skip to content

Commit 8509a6a

Browse files
committed
Add an example demonstrating the use of @trigger for things other than animations
1 parent b13ac04 commit 8509a6a

2 files changed

Lines changed: 37 additions & 24 deletions

File tree

Overview.bs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,25 @@ media queries somehow?
527527
</pre>
528528
</div>
529529

530-
Issue: We should add an example of something that toggles 'visibility' or
531-
even 'display' to demonstrates how ''@trigger'' can be used more widely than
532-
just animations. (Particularly since 'display' can't be animated normally.)
533-
530+
<div class="example">
531+
Using ''@trigger'' for things other than animations
532+
<pre class="lang-css">
533+
/*
534+
Elements with the class 'elusive' are only displayed while the scroll offset
535+
is in the range [200, 300].
536+
Note that 'display' can't be animated normally.
537+
Assume the HTML element has id 'root'
538+
*/
539+
.elusive {
540+
display: none;
541+
}
542+
@trigger scroll(element(#root), vertical, 200px, 300px) {
543+
.elusive {
544+
display: block;
545+
}
546+
}
547+
</pre>
548+
</div>
534549

535550
# Controlling animation playback # {#controlling-animation-playback}
536551

index.html

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,24 @@ <h3 class="heading settled" data-level="3.7" id="trigger-examples"><span class="
794794
<span class="p">}</span>
795795
</pre>
796796
</div>
797-
<p class="issue" id="issue-102d681d"><a class="self-link" href="#issue-102d681d"></a> We should add an example of something that toggles <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css21/visufx.html#propdef-visibility">visibility</a> or
798-
even <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> to demonstrates how <a class="css" data-link-type="maybe" href="#at-ruledef-trigger" id="ref-for-at-ruledef-trigger-5">@trigger</a> can be used more widely than
799-
just animations. (Particularly since <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> can’t be animated normally.)</p>
797+
<div class="example" id="example-c553e53f">
798+
<a class="self-link" href="#example-c553e53f"></a> Using <a class="css" data-link-type="maybe" href="#at-ruledef-trigger" id="ref-for-at-ruledef-trigger-5">@trigger</a> for things other than animations
799+
<pre class="lang-css highlight"><span class="c">/* </span>
800+
<span class="c"> Elements with the class 'elusive' are only displayed while the scroll offset</span>
801+
<span class="c"> is in the range [200, 300].</span>
802+
<span class="c"> Note that 'display' can’t be animated normally.</span>
803+
<span class="c"> Assume the HTML element has id 'root' </span>
804+
<span class="c">*/</span>
805+
<span class="nt">.elusive </span><span class="p">{</span>
806+
<span class="k">display</span><span class="p">:</span> none<span class="p">;</span>
807+
<span class="p">}</span>
808+
<span class="n">@trigger</span> <span class="nf">scroll</span><span class="p">(</span><span class="nf">element</span><span class="p">(</span>#root<span class="p">),</span> vertical<span class="p">,</span> <span class="m">200</span><span class="l">px</span><span class="p">,</span> <span class="m">300</span><span class="l">px</span><span class="p">)</span> <span class="p">{</span>
809+
<span class="nt">.elusive </span><span class="p">{</span>
810+
<span class="k">display</span><span class="p">:</span> block<span class="p">;</span>
811+
<span class="p">}</span>
812+
<span class="p">}</span>
813+
</pre>
814+
</div>
800815
<h2 class="heading settled" data-level="4" id="controlling-animation-playback"><span class="secno">4. </span><span class="content">Controlling animation playback</span><a class="self-link" href="#controlling-animation-playback"></a></h2>
801816
<h3 class="heading settled" data-level="4.1" id="scrolltimeline-interface"><span class="secno">4.1. </span><span class="content">The <code class="idl"><a data-link-type="idl" href="#scrolltimeline" id="ref-for-scrolltimeline-1">ScrollTimeline</a></code> interface</span><a class="self-link" href="#scrolltimeline-interface"></a></h3>
802817
<pre class="idl highlight def"><span class="kt">enum</span> <dfn class="nv dfn-paneled idl-code" data-dfn-type="enum" data-export="" id="enumdef-scrolltimelineautokeyword">ScrollTimelineAutoKeyword</dfn> { <dfn class="s idl-code" data-dfn-for="ScrollTimelineAutoKeyword" data-dfn-type="enum-value" data-export="" data-lt="&quot;auto&quot;|auto" id="dom-scrolltimelineautokeyword-auto">"auto"<a class="self-link" href="#dom-scrolltimelineautokeyword-auto"></a></dfn> };
@@ -1268,11 +1283,6 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
12681283
<li><a href="https://drafts.csswg.org/css-animations-1/#propdef-animation-name">animation-name</a>
12691284
<li><a href="https://drafts.csswg.org/css-animations-1/#propdef-animation-timing-function">animation-timing-function</a>
12701285
</ul>
1271-
<li>
1272-
<a data-link-type="biblio">[css-display-3]</a> defines the following terms:
1273-
<ul>
1274-
<li><a href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a>
1275-
</ul>
12761286
<li>
12771287
<a data-link-type="biblio">[css-overflow-3]</a> defines the following terms:
12781288
<ul>
@@ -1302,11 +1312,6 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
13021312
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>
13031313
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>
13041314
</ul>
1305-
<li>
1306-
<a data-link-type="biblio">[CSS2]</a> defines the following terms:
1307-
<ul>
1308-
<li><a href="https://drafts.csswg.org/css21/visufx.html#propdef-visibility">visibility</a>
1309-
</ul>
13101315
<li>
13111316
<a data-link-type="biblio">[WHATWG-DOM]</a> defines the following terms:
13121317
<ul>
@@ -1353,8 +1358,6 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
13531358
<dl>
13541359
<dt id="biblio-css-animations-1">[CSS-ANIMATIONS-1]
13551360
<dd>CSS Animations Module Level 1 URL: <a href="https://drafts.csswg.org/css-animations-1/">https://drafts.csswg.org/css-animations-1/</a>
1356-
<dt id="biblio-css-display-3">[CSS-DISPLAY-3]
1357-
<dd>Tab Atkins Jr.; Elika Etemad. <a href="http://dev.w3.org/csswg/css-display/">CSS Display Module Level 3</a>. 15 October 2015. WD. URL: <a href="http://dev.w3.org/csswg/css-display/">http://dev.w3.org/csswg/css-display/</a>
13581361
<dt id="biblio-css-overflow-3">[CSS-OVERFLOW-3]
13591362
<dd>David Baron; Florian Rivoal. <a href="http://drafts.csswg.org/css-overflow/">CSS Overflow Module Level 3</a>. 31 May 2016. WD. URL: <a href="http://drafts.csswg.org/css-overflow/">http://drafts.csswg.org/css-overflow/</a>
13601363
<dt id="biblio-css-syntax-3">[CSS-SYNTAX-3]
@@ -1363,8 +1366,6 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
13631366
<dd>Tab Atkins Jr.; Elika Etemad. <a href="http://dev.w3.org/csswg/css-values/">CSS Values and Units Module Level 3</a>. 11 June 2015. CR. URL: <a href="http://dev.w3.org/csswg/css-values/">http://dev.w3.org/csswg/css-values/</a>
13641367
<dt id="biblio-css-writing-modes-3">[CSS-WRITING-MODES-3]
13651368
<dd>Elika Etemad; Koji Ishii. <a href="http://dev.w3.org/csswg/css-writing-modes-3/">CSS Writing Modes Level 3</a>. 15 December 2015. CR. URL: <a href="http://dev.w3.org/csswg/css-writing-modes-3/">http://dev.w3.org/csswg/css-writing-modes-3/</a>
1366-
<dt id="biblio-css2">[CSS2]
1367-
<dd>Bert Bos; et al. <a href="https://www.w3.org/TR/CSS2">Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. REC. URL: <a href="https://www.w3.org/TR/CSS2">https://www.w3.org/TR/CSS2</a>
13681369
<dt id="biblio-html">[HTML]
13691370
<dd>Ian Hickson. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
13701371
<dt id="biblio-rfc2119">[RFC2119]
@@ -1506,9 +1507,6 @@ <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content
15061507
<div class="issue"> Do we need <a class="property" data-link-type="propdesc" href="#propdef-animation-trigger">animation-trigger</a> at all, or is <a class="css" data-link-type="maybe" href="#at-ruledef-trigger">@trigger</a> sufficient?<a href="#issue-7c802841"></a></div>
15071508
<div class="issue"> Should this be called ‘@scroll’ perhaps? Or integrated with
15081509
media queries somehow?<a href="#issue-f02ea5ba"></a></div>
1509-
<div class="issue"> We should add an example of something that toggles <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css21/visufx.html#propdef-visibility">visibility</a> or
1510-
even <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> to demonstrates how <a class="css" data-link-type="maybe" href="#at-ruledef-trigger">@trigger</a> can be used more widely than
1511-
just animations. (Particularly since <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> can’t be animated normally.)<a href="#issue-102d681d"></a></div>
15121510
<div class="issue"> A <code class="idl"><a data-link-type="idl" href="#scrolltrigger">ScrollTrigger</a></code> is only active when the scroll offset is within the range,
15131511
and a timeline is inactive when its trigger is inactive. How can we reconcile
15141512
this will fill modes, which require an active timeline outside the range in

0 commit comments

Comments
 (0)