Skip to content

Commit d35d97b

Browse files
committed
[css-easing-2][editorial] Line up steps() serializing/output with the structure of linear() too.
1 parent d63a352 commit d35d97b

File tree

1 file changed

+34
-119
lines changed

1 file changed

+34
-119
lines changed

css-easing-2/Overview.bs

Lines changed: 34 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,37 @@ The ''jump-*'' keywords values are illustrated below:
859859
</figcaption>
860860
</figure>
861861

862-
</dl>
862+
863+
864+
865+
<h4 id=steps-serialization>
866+
Serializing</h4>
867+
868+
Unlike the other [=easing function=] keywords,
869+
''step-start'' and ''step-end'' <em>do not</em> serialize as themselves.
870+
Instead, they serialize as "steps(1, start)" and "steps(1)", respectively.
871+
872+
<div algorithm>
873+
To <dfn export>serialize a steps() functions</dfn>:
874+
875+
1. Let |s| be the string "steps(".
876+
877+
2. Serialize the function's [=steps()/steps=],
878+
and append it to |s|.
879+
880+
3. If the function's [=steps()/step position=] is ''end'' or ''jump-end'',
881+
append ")" to |s| and return |s|.
882+
883+
4. Otherwise, append ", " to |s|.
884+
Serialize the [=steps()/step position=] as a keyword,
885+
and append the result to |s|.
886+
Append ")" to |s|.
887+
Return |s|.
888+
</div>
889+
890+
<wpt>
891+
timing-functions-syntax-computed.html
892+
</wpt>
863893

864894
<h4 id=step-easing-algo oldids=step-timing-function-algo>
865895
Output</h4>
@@ -881,9 +911,9 @@ Output</h4>
881911
each with an associated value,
882912
as follows:
883913

884-
1. [-&infin;, 0] has the value 0.
885-
2. (1, &infin;] has the value 1.
886-
3. [0, 1] is divided into |steps| intervals,
914+
1. [-&infin;, 0) has the value 0.
915+
2. [1, &infin;] has the value 1.
916+
3. [0, 1) is divided into |steps| half-open intervals,
887917
[0, ...) to [..., 1)
888918
with their values assigned as defined for the |position|
889919
(see <<step-position>>).
@@ -896,125 +926,10 @@ Output</h4>
896926
for the interval that |inputProgress| is in.
897927
</div>
898928

899-
<div class=example>
900-
901-
As an example of how the [=before flag=] affects the behavior of this function,
902-
consider an animation with a [=step easing function=] whose [=step
903-
position=] is <a value for="steps()">start</a> and which has a positive
904-
delay and backwards fill.
905-
906-
For example, using CSS animation:
907-
908-
<pre class='lang-css'>
909-
animation: moveRight 5s 1s steps(5, start);
910-
</pre>
911-
912-
During the delay phase, the [=input progress value=] will be zero but if the
913-
[=before flag=] is set to indicate that the animation has yet to reach its
914-
animation interval, the easing function will produce zero as its [=output
915-
progress value=], i.e. the bottom of the first step.
916-
917-
At the exact moment when the animation interval begins, the [=input progress
918-
value=] will still be zero, but the [=before flag=] will not be set and hence
919-
the result of the easing function will correspond to the top of the first step.
920-
</div>
921-
922-
For the purposes of calculating the [=output progress value=], the
923-
[=step position=] <a value for="steps()">start</a> is considered equivalent to
924-
<a value for="steps()">jump-start</a>.
925-
Likewise <a value for="steps()">end</a> is considered equivalent to <a value
926-
for="steps()">jump-end</a>.
927-
As a result, the following algorithm does not make explicit reference to
928-
<a value for="steps()">start</a> or <a value for="steps()">end</a>.
929-
930-
Note: User agents must still differentiate between
931-
<a value for="steps()">jump-start</a> and <a value for="steps()">start</a> for
932-
the purpose of serialization (see [[#serialization]]).
933-
934-
The [=output progress value=] is calculated from the [=input progress value=]
935-
and [=before flag=] as follows:
936-
937-
1. Calculate the <var>current step</var> as
938-
<code>floor([=input progress value=] &times; [=steps=])</code>.
939-
940-
1. If the [=step position=] property is one of:
941-
942-
* <a value for="steps()">jump-start</a>,
943-
* <a value for="steps()">jump-both</a>,
944-
945-
increment <var>current step</var> by one.
946-
947-
1. If <em>both</em> of the following conditions are true:
948-
949-
* the [=before flag=] is set, <em>and</em>
950-
* [=input progress value=] &times; [=steps=] mod 1 equals zero
951-
(that is, if [=input progress value=] &times; [=steps=] is
952-
integral), then
953-
954-
decrement <var>current step</var> by one.
955-
956-
1. If [=input progress value=] &ge; 0 and <var>current step</var> &lt; 0,
957-
let <var>current step</var> be zero.
958-
959-
1. Calculate |jumps| based on the [=step position=] as follows:
960-
961-
: <a value for="steps()">jump-start</a> or
962-
<a value for="steps()">jump-end</a>
963-
:: [=steps=]
964-
: <a value for="steps()">jump-none</a>
965-
:: [=steps=] - 1
966-
: <a value for="steps()">jump-both</a>
967-
:: [=steps=] + 1
968-
969-
1. If [=input progress value=] &le; 1 and <var>current step</var> &gt;
970-
|jumps|, let <var>current step</var> be |jumps|.
971-
972-
<div class=note>
973-
974-
Steps 4 and 6 in this procedure ensure that given an [=input progress
975-
value=] in the range [0, 1], a step easing function does not produce an
976-
[=output progress value=] outside that range.
977-
978-
For example, although mathematically we might expect that a step easing
979-
function with a [=step position=] of <a value for="steps()">jump-start</a>
980-
would step up (i.e. beyond 1) when the [=input progress value=] is 1,
981-
intuitively,
982-
when we apply such an easing function to a forwards-filling animation,
983-
we expect it to produce an [=output progress value=] of 1
984-
as the animation fills forwards.
985-
986-
A similar situation arises for a step easing function with
987-
a [=step position=] of <a value for="steps()">jump-end</a>
988-
when applied to an animation during its delay phase.
989-
990-
</div>
991-
992-
1. The [=output progress value=] is <code><var>current step</var> /
993-
|jumps|</code>.
994-
995929
<wpt>
996930
step-timing-functions-output.html
997931
</wpt>
998932

999-
<h3 id=serialization oldids=serializing-a-timing-function>Serialization</h3>
1000-
1001-
Easing functions are serialized using the common serialization patterns
1002-
defined in [[CSSOM]] with the following additional requirements:
1003-
1004-
* Step easing functions, whether they are specified using the
1005-
''steps()'' function or either of the ''step-start'' or ''step-end''
1006-
keywords, are serialized as follows:
1007-
1008-
1. If the [=step position=] is ''jump-end'' or ''end'', serialize
1009-
as <a lt="steps()" function>steps(&lt;integer&gt;)</a>.
1010-
1011-
2. Otherwise, serialize as <a lt="steps()"
1012-
function>steps(&lt;integer&gt;, &lt;step-position&gt;)</a>.
1013-
1014-
<wpt>
1015-
timing-functions-syntax-computed.html
1016-
</wpt>
1017-
1018933
<h2 class=no-num id=privacy>Privacy Considerations</h2>
1019934

1020935
<!-- Horizontal review wants Security and Privacy sections to be separate. -->

0 commit comments

Comments
 (0)