Skip to content

Commit 8d80329

Browse files
DavMilatabatkins
andauthored
[css-animations-2] Define trigger scope (#13241)
* Define trigger-scope * Flat tree; remove anchor-scope reference * Apply suggestion from @tabatkins * light editorial rewrite Combine some sections and reword a few bits. --------- Co-authored-by: David Awogbemila <awogbemila@chromium.org> Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
1 parent 8fadebb commit 8d80329

1 file changed

Lines changed: 62 additions & 17 deletions

File tree

css-animations-2/Overview.bs

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ of what can be achieved with the Web Animations API in Javascript,
813813
allowing simple, common interaction patterns
814814
to be created and managed purely in CSS.
815815

816-
Currently, two types of <dfn export for=CSS>triggers</dfn> are defined:
816+
Currently, two types of <dfn export for=CSS lt="trigger">triggers</dfn> are defined:
817817

818818
* [=timeline triggers=], managed by the 'timeline-trigger' properties,
819819
which allow animations to be triggered by entering or leaving certain timeline ranges.
@@ -826,7 +826,7 @@ Currently, two types of <dfn export for=CSS>triggers</dfn> are defined:
826826
such as clicking an element or pressing certain keys.
827827

828828
A [=trigger=] is <em>defined</em> on some specific triggering element.
829-
All triggers have a name,
829+
All triggers have a <dfn export for=CSS>trigger name</dfn>,
830830
and the specific type of trigger dictates how and when it's activated.
831831
A trigger can define multiple "types" of activation.
832832
(For example, [=timeline triggers=] can do different things on entry and exit.)
@@ -844,30 +844,75 @@ is intentionally somewhat generic,
844844
intended to support using [=triggers=] for <em>other</em> purposes in the future.
845845
For now, though, [=triggered animations=] are the only user of this feature.
846846

847-
848-
<h3 id="trigger-scope">
849-
Trigger Scope/Resolution</h3>
850-
851-
All [=triggers=] are document-global by default,
852-
similar to <l spec="css-anchor-position-1">[=anchor names=]</l>.
853-
854847
If a single element attempts to define multiple [=triggers=] of different types
855-
with the same name,
856-
it only exposes one of them,
848+
with the same [=trigger name=],
849+
it only exposes one of the [=triggers=],
857850
with [=event triggers=] winning over [=timeline triggers=].
858851

859852
Note: This order is completely arbitrary
860853
(based on alphabetic order of the concept name),
861854
as this is just an error case.
862855

863-
If multiple elements define [=triggers=] with the same name,
856+
857+
<h3 id="trigger-scope">
858+
Trigger Name Scoping: the 'trigger-scope' property</h3>
859+
860+
[=Trigger names=] are global by default,
861+
usable by other elements regardless of their position.
862+
(Though they are [=tree-scoped names=],
863+
so have interactions with [=shadow roots=]).
864+
If multiple elements define [=triggers=] with the same [=trigger name=],
864865
the [=trigger=] defined by the later element in [=tree order=] is used.
865866

866-
Note: This behavior will be improved by a <css>trigger-scope</css> property,
867-
not yet defined,
868-
letting you define triggers that are only visible to subtrees
869-
and references that only search in that subtree
870-
(just like 'anchor-scope').
867+
The 'trigger-scope' property can limit the scope of a name
868+
to a subtree of the document,
869+
so elements outside won't see the chosen [=trigger name=],
870+
and elements inside will only see the version of the [=trigger name=]
871+
defined inside the scope.
872+
873+
<pre class=propdef>
874+
Name: trigger-scope
875+
Value: none | all | <<dashed-ident>>#
876+
Initial: none
877+
Applies to: all elements
878+
Inherited: no
879+
Animation type: not animatable
880+
Computed value: as specified
881+
</pre>
882+
883+
This property scopes [=trigger names=] to the subtree of the matching element.
884+
Its values are:
885+
886+
<dl dfn-for="trigger-scope" dfn-type=value>
887+
<dt><dfn>none</dfn>
888+
<dd>
889+
No changes in [=trigger name=] scope.
890+
891+
<dt><dfn>all</dfn>
892+
<dd>
893+
Specifies that all [=trigger names=] defined by this element or its descendants--
894+
whose scope is not already limited by a descendant using 'trigger-scope'--
895+
to be in scope only for this element's [=flat tree=] descendants;
896+
and limits descendants to only match [=trigger names=]
897+
to [=triggers=] within this subtree.
898+
899+
This value only affects [=trigger names=] in the same tree scope,
900+
as if it were a [=tree-scoped name/strictly matched=] [=tree-scoped name=].
901+
(That is, ''trigger-scope: all'' acts identically
902+
to ''trigger-scope: --foo, --bar, ...'',
903+
listing all relevant [=trigger names=].)
904+
905+
<dt><dfn><<dashed-ident>></dfn>
906+
<dd>
907+
Specifies that a matching [=trigger name=] defined by this element or its descendants--
908+
whose scope is not already limited by a descendant using 'trigger-scope'--
909+
to be in scope only for this element's [=flat tree=] descendants;
910+
and limits descendants to only match these [=trigger names=]
911+
to [=triggers=] within this subtree.
912+
913+
The <<dashed-ident>> represents a [=tree-scoped name/strictly matched=] [=tree-scoped name=],
914+
i.e. it can only match against [=trigger names=] in the same shadow tree.[[!CSS-SCOPING-1]]
915+
</dl>
871916

872917
<!-- Big Text: timeline
873918

0 commit comments

Comments
 (0)