Skip to content

Commit fde5f1b

Browse files
committed
[css-easing-2][editorial] Rewrite the step output algo to have parallel structure with linear.
1 parent f09a271 commit fde5f1b

File tree

1 file changed

+54
-24
lines changed

1 file changed

+54
-24
lines changed

css-easing-2/Overview.bs

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ If easing functions are used outside of the CSS context,
164164
care must be taken to either correctly handle potential infinities,
165165
or clamp the [=output progress value=].
166166

167-
Some types of easing functions also take an additional boolean [=before flag=]
168-
input which is defined subsequently.
167+
Some types of easing functions also take an additional boolean <dfn export for="easing function">before flag</dfn>,
168+
which is defined subsequently.
169169

170170
This specification defines four types of easing functions whose definitions
171171
follow.
@@ -700,7 +700,8 @@ infinitely using tangent of the curve at the closest endpoint as follows:
700700
███▌ █▌ █████▌ █▌ ███▌
701701
-->
702702

703-
<h3 id=step-easing-functions oldids=step-timing-functions>Step easing functions:
703+
<h3 id=step-easing-functions oldids=step-timing-functions>
704+
Step Easing Functions:
704705
''step-start'', ''step-end'', ''steps()''</h3>
705706

706707
A <dfn>step easing function</dfn> is an [=easing function=]
@@ -821,34 +822,63 @@ The ''jump-*'' keywords values are illustrated below:
821822
<h4 id=step-easing-algo oldids=step-timing-function-algo>
822823
Output</h4>
823824

824-
At the exact point where a step occurs, the result of the function is
825-
conceptually the top of the step. However, an additional <dfn>before flag</dfn>
826-
passed as input to the [=step easing function=], if true, will cause the
827-
result of the function to correspond to the bottom of the step at the step
828-
point.
825+
<div class=algorithm>
826+
To <dfn export>calculate step easing output progress</dfn>
827+
for a given [=step easing function=] |func|,
828+
an [=input progress value=] |inputProgress|,
829+
and an optional [=before flag=] (defaulting to false),
830+
perform the following.
831+
It returns an [=output progress value=].
829832

830-
<div class=example>
833+
1. Let |steps| be |func|'s [=steps()/steps=],
834+
and |position| be |func|'s [=steps()/step position=].
831835

832-
As an example of how the [=before flag=] affects the behavior of this function,
833-
consider an animation with a [=step easing function=] whose [=step
834-
position=] is <a value for="steps()">start</a> and which has a positive
835-
delay and backwards fill.
836+
2. Divide the interval [-&infin;, &infin;] into several segments,
837+
each with an associated value,
838+
as follows:
836839

837-
For example, using CSS animation:
840+
1. [-&infin;, 0] has the value 0.
841+
2. [1, &infin;] has the value 1.
842+
3. [0, 1] is divided into |steps| intervals,
843+
with their values assigned as defined for the |position|
844+
(see <<step-position>>).
838845

839-
<pre class='lang-css'>
840-
animation: moveRight 5s 1s steps(5, start);
841-
</pre>
846+
Note: All intervals are inclusive,
847+
so some values are part of two intervals at once.
848+
849+
3. If |inputProgress| is in a single interval,
850+
return the associated value for that interval.
851+
852+
4. Otherwise, |inputProgress| is in two intervals,
853+
with two associated values
854+
(which might be the same).
855+
856+
If the [=before flag=] is true,
857+
return the smaller associated value;
858+
otherwise, return the larger associated value.
859+
</div>
860+
861+
<div class=example>
862+
863+
As an example of how the [=before flag=] affects the behavior of this function,
864+
consider an animation with a [=step easing function=] whose [=step
865+
position=] is <a value for="steps()">start</a> and which has a positive
866+
delay and backwards fill.
867+
868+
For example, using CSS animation:
842869

843-
During the delay phase, the [=input progress value=] will be zero but if the
844-
[=before flag=] is set to indicate that the animation has yet to reach its
845-
animation interval, the easing function will produce zero as its [=output
846-
progress value=], i.e. the bottom of the first step.
870+
<pre class='lang-css'>
871+
animation: moveRight 5s 1s steps(5, start);
872+
</pre>
847873

848-
At the exact moment when the animation interval begins, the [=input progress
849-
value=] will still be zero, but the [=before flag=] will not be set and hence
850-
the result of the easing function will correspond to the top of the first step.
874+
During the delay phase, the [=input progress value=] will be zero but if the
875+
[=before flag=] is set to indicate that the animation has yet to reach its
876+
animation interval, the easing function will produce zero as its [=output
877+
progress value=], i.e. the bottom of the first step.
851878

879+
At the exact moment when the animation interval begins, the [=input progress
880+
value=] will still be zero, but the [=before flag=] will not be set and hence
881+
the result of the easing function will correspond to the top of the first step.
852882
</div>
853883

854884
For the purposes of calculating the [=output progress value=], the

0 commit comments

Comments
 (0)