Skip to content

Commit 4ec10ae

Browse files
committed
[css-animations-2] Separate trigger concept from trigger instance. Define that event triggers can be defined to have enter/exit pairs, like timelines.
1 parent 680e999 commit 4ec10ae

File tree

1 file changed

+103
-25
lines changed

1 file changed

+103
-25
lines changed

css-animations-2/Overview.bs

Lines changed: 103 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ Its values are:
743743
How many <<animation-action>>s a trigger accepts,
744744
and what exactly activates them,
745745
is determined by the type of the trigger.
746-
<span class=note>([=Event triggers=] only take a single <<animation-action>>,
747-
while [=timeline triggers=] can take one or two.)</span>
746+
<span class=note>([=Event triggers=] take one and possibly an optional second, depending on whether they're stateless or stateful;
747+
[=timeline triggers=] take one and optionally a second.)</span>
748748
Specifying the wrong number of actions
749749
(too many or too few)
750750
is valid syntactically,
@@ -785,6 +785,18 @@ The 'animation' shorthand property syntax is as follows:
785785

786786
<span class=prod><dfn>&lt;single-animation></dfn> = <<'animation-duration'>> || <<easing-function>> || <<'animation-delay'>> || <<single-animation-iteration-count>> || <<single-animation-direction>> || <<single-animation-fill-mode>> || <<single-animation-play-state>> || [ none | <<keyframes-name>> ] || <<single-animation-timeline>></span>
787787

788+
789+
<!-- Big Text: triggers
790+
791+
█████▌ ████▌ ████ ███▌ ███▌ █████▌ ████▌ ███▌
792+
█▌ █▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
793+
█▌ █▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌
794+
█▌ ████▌ ▐▌ █▌ ██▌ █▌ ██▌ ████ ████▌ ███▌
795+
█▌ █▌▐█ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌▐█ █▌
796+
█▌ █▌ ▐█ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█ █▌ █▌
797+
█▌ █▌ █▌ ████ ███▌ ███▌ █████▌ █▌ █▌ ███▌
798+
-->
799+
788800
<h2 id="animation-triggers">
789801
Triggers</h2>
790802

@@ -819,14 +831,13 @@ A trigger can define multiple "types" of activation.
819831
(For example, [=timeline triggers=] can do different things on entry and exit.)
820832

821833
A [=trigger=] is <em>used</em> on potentially any element,
822-
for some specific purpose
823-
(currently, just 'animation-trigger').
824-
A trigger-using element specifies what trigger(s) it's listening to,
825-
and what actions
826-
(currently, just <<animation-action>>s)
827-
to do in response to that activation.
828-
829-
Note: This design for [=triggers=],
834+
creating a <dfn export for=CSS>trigger instance</dfn> on the element.
835+
(For example, 'animation-trigger' associates a [=trigger instance=]
836+
with a specific animation on the element.)
837+
The trigger-using element specifies what actions to take
838+
when the [=trigger=] activates.
839+
840+
Note: This design for [=triggers=] and [=trigger instances=],
830841
and the way they're associated with [=triggered animations=] and <<animation-action>>s,
831842
is intentionally somewhat generic,
832843
intended to support using [=triggers=] for <em>other</em> purposes in the future.
@@ -857,6 +868,17 @@ letting you define triggers that are only visible to subtrees
857868
and references that only search in that subtree
858869
(just like 'anchor-scope').
859870

871+
<!-- Big Text: timeline
872+
873+
█████▌ ████ █ █ █████▌ █▌ ████ █ █▌ █████▌
874+
█▌ ▐▌ ██ ██ █▌ █▌ ▐▌ █▌ █▌ █▌
875+
█▌ ▐▌ █▌█ █▐█ █▌ █▌ ▐▌ ██▌ █▌ █▌
876+
█▌ ▐▌ █▌ █ ▐█ ████ █▌ ▐▌ █▌▐█ █▌ ████
877+
█▌ ▐▌ █▌ ▐█ █▌ █▌ ▐▌ █▌ ██▌ █▌
878+
█▌ ▐▌ █▌ ▐█ █▌ █▌ ▐▌ █▌ █▌ █▌
879+
█▌ ████ █▌ ▐█ █████▌ █████ ████ █▌ ▐▌ █████▌
880+
-->
881+
860882
<h3 id="timeline-triggers">
861883
Timeline Triggers</h3>
862884

@@ -867,16 +889,16 @@ or leaves the trigger's <dfn export for="timeline trigger">exit range</dfn>.
867889
It is defined on an element with the 'timeline-trigger' shorthand property,
868890
or its longhands.
869891

870-
A [=timeline trigger=] has a binary <dfn export for="timeline trigger">trigger state</dfn> associated with it;
892+
A [=timeline trigger=] [=trigger instance=] has a binary <dfn export for="timeline trigger">trigger state</dfn> associated with it;
871893
it is initially "untriggered".
872894
While it's "untriggered",
873895
the associated [=timeline=] entering (or starting in) the trigger's [=enter range=]
874896
performs an associated <dfn export for="timeline trigger">enter action</dfn>
875-
and switches the [=trigger state=] to "triggered";
897+
and switches the [=timeline trigger/trigger state=] to "triggered";
876898
while it's "triggered",
877899
the associated timeline <em>leaving</em> the trigger's [=exit range=]
878900
performs an associated <dfn export for="timeline trigger">exit action</dfn>
879-
and switches the [=trigger state=] to "untriggered".
901+
and switches the [=timeline-trigger/trigger state=] to "untriggered".
880902

881903
Note: By default, the [=exit range=] is the same as the [=enter range=];
882904
even when manually specified,
@@ -1062,6 +1084,16 @@ rather than being settable in any order as is more common.
10621084
Issue: I think we need the ''/'' to disambiguate the two ranges?
10631085

10641086

1087+
<!-- Big Text: event
1088+
1089+
█████▌ █▌ █▌ █████▌ █ █▌ █████▌
1090+
█▌ █▌ █▌ █▌ █▌ █▌ █▌
1091+
█▌ █▌ █▌ █▌ ██▌ █▌ █▌
1092+
████ ▐▌ █ ████ █▌▐█ █▌ █▌
1093+
█▌ █ ▐▌ █▌ █▌ ██▌ █▌
1094+
█▌ ▐▌ █ █▌ █▌ █▌ █▌
1095+
█████▌ ▐█ █████▌ █▌ ▐▌ █▌
1096+
-->
10651097

10661098
<h3 id="event-triggers">
10671099
Event Triggers</h3>
@@ -1071,8 +1103,39 @@ which is activated when certain {{Event}}s are fired at the element.
10711103
It is defined on an element with the 'event-trigger' shorthand property,
10721104
or its longhands.
10731105

1074-
An [=event trigger=] only has a single action associated with it,
1075-
which it performs every time the trigger is activated.
1106+
An [=event trigger=] can be defined as either stateless or stateful:
1107+
1108+
* If stateless, it has a single set of <dfn for="event trigger" lt="enter event">enter events</dfn>
1109+
that activate it.
1110+
* If stateful, it has two sets of events, its [=enter events=]
1111+
and another set of <dfn for="event trigger" lt="exit event">exit events</dfn>.
1112+
1113+
[=Event triggers=] are activated when one of its associated {{Event}}s are fired on the page
1114+
with the trigger-defining element as its {{Event/target}}.
1115+
If it's stateful,
1116+
then its [=trigger instance=] has a binary <dfn export for="event trigger">trigger state</dfn>
1117+
associated with it,
1118+
initially "untriggered":
1119+
while "untriggered", it only activates when the [=event trigger=] receives one of its [=enter events=],
1120+
performing an associated <dfn export for="event trigger">enter action</dfn>
1121+
and switching its [=event trigger/trigger state=] to "triggered";
1122+
while "triggered", it only activates when it receives one of its [=exit events=],
1123+
performing an associated <dfn export for="event trigger">exit action</dfn>
1124+
and switching its [=event trigger/trigger state=] back to "untriggered".
1125+
1126+
A stateless [=event trigger=] must be given exactly one action for its [=trigger instance=].
1127+
A stateful one can be given one or two:
1128+
the first is its [=event trigger/enter action=],
1129+
and the second, if provided, is its [=event trigger/exit action=];
1130+
if the second is not provided,
1131+
the [=event trigger/exit action=] is to do nothing.
1132+
1133+
Note: A stateful and stateless [=event trigger=] act differently
1134+
even if you only assign a single action;
1135+
a single-action stateful [=event trigger=] will effectively "turn off"
1136+
until it receives one of its [=exit events=],
1137+
ignoring any of the [=enter events=] after the first,
1138+
while a stateless one will repeatedly trigger for every [=enter event=].
10761139

10771140
An element can define multiple [=event triggers=],
10781141
using the same {{Event}}s or different ones.
@@ -1082,6 +1145,11 @@ with 'event-trigger-name' as the [=coordinating list base property=],
10821145
and each item in the [=coordinated value list=]
10831146
defining the properties of a single [=event trigger=].
10841147

1148+
Issue: The proposal I drew this text from
1149+
specified that it only cares if the element is the *target* of the event.
1150+
We probably want to allow for bubbling and/or capturing,
1151+
possibly as an opt in/out.
1152+
10851153

10861154
<h4 id="event-trigger-name">
10871155
Naming the Trigger: the 'event-trigger-name' property</h4>
@@ -1110,7 +1178,7 @@ Linking an Event: the 'event-trigger-source' property</h4>
11101178

11111179
<pre class=propdef>
11121180
Name: event-trigger-source
1113-
Value: [ none | <<event-trigger-event>>+ ]#
1181+
Value: [ none | <<event-trigger-event>>+ [ / <<event-trigger-event>>+ ]? ]#
11141182
Initial: none
11151183
Applies to: all elements
11161184
Inherited: no
@@ -1121,22 +1189,32 @@ Animation type: not animatable
11211189

11221190
The 'event-trigger-source' property
11231191
specifies what event or events activate the [=event trigger=].
1192+
Its values are:
1193+
1194+
<dl dfn-type=value dfn-for=event-trigger-source>
1195+
: <dfn>none</dfn>
1196+
:: The corresponding entry in the [=coordinated value list=] does not define a trigger.
1197+
1198+
: <dfn><<event-trigger-event>>+ [ / <<event-trigger-event>>+ ]?</dfn>
1199+
:: Defines what event(s) the [=event trigger=] responds to.
1200+
1201+
If a ''/'' is used in the value,
1202+
the [=event trigger=] is stateful;
1203+
the set of events before the ''/'' are the [=event trigger's=] [=enter events=],
1204+
while those after the ''/'' are the [=exit events=].
1205+
(The same events can occur in both sets.)
1206+
1207+
Otherwise,
1208+
the [=event trigger=] is stateless,
1209+
and the provided events are its [=enter events=].
1210+
</dl>
11241211

11251212
<pre class=prod>
11261213
<dfn><<event-trigger-event>></dfn> = activate | click | touch | dblclick | keypress(<<string>>) | ...
11271214
</pre>
11281215

1129-
Whenever any of the specified {{Event}}s are fired
1130-
with this element as its {{Event/target}},
1131-
the [=event target=] activates.
1132-
11331216
Issue: Figure out the full set of events we want to handle.
11341217

1135-
Issue: The proposal I drew this text from
1136-
specified that it only cares if the element is the *target* of the event.
1137-
We probably want to allow for bubbling and/or capturing,
1138-
possibly as an opt in/out.
1139-
11401218

11411219
<h4 id="event-trigger-shorthand">
11421220
The 'event-trigger' Shorthand</h4>

0 commit comments

Comments
 (0)