Skip to content

Commit ec69053

Browse files
committed
[css-timing] Add frames() timing function
Based on many discussions about this on the www-style list, the latest concluding here: https://lists.w3.org/Archives/Public/www-style/2016Mar/0199.html
1 parent c96ddfa commit ec69053

File tree

3 files changed

+234
-3
lines changed

3 files changed

+234
-3
lines changed

css-animations/Overview.bs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn; sp
4747
text: event handler IDL attributes
4848
urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn; spec: html
4949
text: HTML elements
50+
url: https://drafts.csswg.org/css-timing-1/#after-flag; type: dfn; text: after flag; spec: css-timing
5051
</pre>
5152
<pre class="link-defaults">
5253
spec:cssom-1; type:interface; text:CSSRule
@@ -571,6 +572,8 @@ The 'animation-timing-function' property</h3>
571572
The <a spec=css-timing>input progress value</a> used is the percentage
572573
of the time elapsed between the current keyframe and the next keyframe
573574
<em>after</em> incorporating the effect of the 'animation-direction' property.
575+
The <a spec=css-timing>after flag</a> is true when the animation has ended
576+
and is false otherwise.
574577

575578
During the 'animation-delay', the 'animation-timing-function' is not applied.
576579

css-timing/Overview.bs

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ range [-&infin;, &infin;].
8686
Some types of timing function also take an additional boolean [=before flag=]
8787
input which is defined subsequently.
8888

89-
This specification defines three types of timing functions whose definitions
89+
This specification defines four types of timing functions whose definitions
9090
follow.
9191

9292

@@ -203,7 +203,7 @@ Step timing functions {#step-timing-functions}
203203

204204
A <dfn>step timing function</dfn> is a type of <a>timing function</a>
205205
that divides the input time into a specified number of intervals that
206-
are equal in duration.
206+
are equal in length.
207207

208208
Some example step timing functions are illustrated below.
209209

@@ -301,6 +301,69 @@ The meaning of each value is as follows:
301301

302302
</dl>
303303

304+
Frames timing functions {#frames-timing-functions}
305+
-----------------------
306+
307+
A <dfn>frames timing function</dfn> is a type of <a>timing function</a>
308+
that divides the input time into a specified number of intervals of equal
309+
length, each of which is associated with an <a>output progress value</a> of
310+
increasing value.
311+
The difference between a [=frames timing function=] and a [=step timing
312+
function=] is that a frames timing function returns the [=output progress
313+
values=] 0 and 1 for an equal portion of the [=input progress values=] in
314+
the range [0, 1].
315+
This makes it suitable, for example, for using in animation loops where the
316+
animation should display the first and last frame of the animation for an equal
317+
amount of time as each other frame during each loop.
318+
319+
Some example frames timing functions are illustrated below.
320+
321+
<figure>
322+
<img src="frames-timing-func-examples.svg" width="500"
323+
alt="Example frames timing functions.">
324+
<figcaption>
325+
Example frames timing functions.
326+
In each case the domain is the input progress whilst the range
327+
represents the output progress produced by the function.
328+
</figcaption>
329+
</figure>
330+
331+
A [=frames timing function=] is defined by an integral number of
332+
<dfn>frames</dfn> greater than one.
333+
334+
As with [=step timing functions=], at the exact point where a step occurs the
335+
result of the function is conceptually the top of the step.
336+
An additional <dfn>after flag</dfn> passed as input to the [=step timing
337+
function=], if true, will cause the result of the function to correspond to
338+
the bottom of the step at the step point.
339+
340+
The [=output progress value=] is calculated from the [=input progress value=]
341+
and [=after flag=] as follows:
342+
343+
1. Calculate the <var>current frame</var> as <code>floor([=input progress
344+
value=] &times; [=frames=])</code>.
345+
346+
1. If <em>both</em> of the following conditions are true:
347+
348+
* the [=after flag=] is set, <em>and</em>
349+
* [=input progress value=] &times; [=frames=] mod 1 equals zero
350+
(that is, if [=input progress value=] &times; [=frames=] is
351+
integral), then
352+
353+
decrement <var>current frame</var> by one.
354+
355+
1. The [=output progress value=] is <code><var>current frame</var>
356+
/ ([=frames=] - 1)</code>.
357+
358+
The syntax for specifying a frames timing function is as follows:
359+
360+
<div class="prod"><dfn type>&lt;frames-timing-function&gt;</dfn> =
361+
<span class="atom"><dfn lt="frames()" function>frames(<<integer>>)</dfn></span></div>
362+
363+
The parameter to the function specifies the number of [=frames=].
364+
It must be a positive integer greater than 1.
365+
366+
304367
The &lt;single-timing-function&gt; production {#single-timing-function-production}
305368
=============================================
306369

@@ -309,7 +372,8 @@ The syntax for specifying a [=timing function=] is as follows:
309372
<div class="prod"><dfn type>&lt;single-timing-function&gt;</dfn> =
310373
''linear'' |
311374
<<cubic-bezier-timing-function>> |
312-
<<step-timing-function>></div>
375+
<<step-timing-function>> |
376+
<<frames-timing-function>></div>
313377

314378
Serialization {#serializing-a-timing-function}
315379
-------------
Lines changed: 164 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)