@@ -338,7 +338,8 @@ Canonical order: per grammar
338338</pre>
339339
340340The 'scroll-container-name' property defines a custom identifier for a [=scroll container=] ,
341- which allows the scroll container to be referred to by the 'animation-trigger' property.
341+ which allows the scroll container to be referred to by the 'animation-trigger' property
342+ (and possibly other properties in the future).
342343
343344Each 'scroll-container-name' value in a document should be unique; if multiple scroll
344345containers in a document have the same 'scroll-container-name' , references to that name
@@ -417,6 +418,87 @@ Issue: Do we need 'animation-trigger' at all, or is ''@trigger'' sufficient?
417418
418419## Examples ## {#trigger-examples}
419420
421+ <div class="example">
422+ <pre class="lang-javascript">
423+ // Spin an element while the page's vertical scroll offset is within a range
424+ let spinner = document.getElementById("spinner");
425+ let effect = new KeyframeEffect(
426+ spinner,
427+ [
428+ { transform: 'rotate(0)' },
429+ { transform: 'rotate(1turn)' }
430+ ],
431+ {
432+ duration: 300,
433+ fill: 'both' ,
434+ easing: 'linear'
435+ });
436+ let timeline = new DocumentTimeline({
437+ trigger: new ScrollTrigger({
438+ scrollSource: document.documentElement,
439+ orientation: "vertical",
440+ kind: "range",
441+ scrollOffset: "500px",
442+ endScrollOffset: "1000px"
443+ });
444+ });
445+ let animation = new Animation(effect, timeline);
446+ animation.play();
447+ </pre>
448+ </div>
449+
450+ <div class="example">
451+ <pre class="lang-css">
452+ /* The same thing with CSS, using animation-trigger */
453+ @keyframes spin {
454+ from {
455+ transform: rotate(0);
456+ }
457+ to {
458+ transform: rotate(1turn);
459+ }
460+ }
461+ html {
462+ scroll-container-name: root;
463+ }
464+ #spinner {
465+ animation-name: spin;
466+ animation-duration: 300ms;
467+ animation-fill-mode: both;
468+ animation-iteration-count: infinite;
469+ animation-timing-function: linear;
470+ animation-trigger: scroll(root, vertical, 500px, 1000px);
471+ }
472+ </pre>
473+ </div>
474+
475+ <div class="example">
476+ <pre class="lang-css">
477+ /* The same thing with CSS, using @trigger */
478+ @keyframes spin {
479+ from {
480+ transform: rotate(0);
481+ }
482+ to {
483+ transform: rotate(1turn);
484+ }
485+ }
486+ html {
487+ scroll-container-name: root;
488+ }
489+ @trigger scroll(root, vertical, 500px, 1000px) {
490+ #spinner {
491+ animation-name: spin;
492+ animation-duration: 300ms;
493+ animation-fill-mode: both;
494+ animation-iteration-count: infinite;
495+ animation-timing-function: linear;
496+ }
497+ }
498+ </pre>
499+ </div>
500+
501+
420502# Controlling animation playback # {#controlling-animation-playback}
421503
422504## The {{ScrollTimeline}} interface ## {#scrolltimeline-interface}
0 commit comments