GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing drafts.csswg.org — CSS Easing Functions Module Level 2 1. IntroductionThis section is not normative. It is often desirable to control the rate at which some value changes. For example, gradually increasing the speed at which an element moves can give the element a sense of weight as it appears to gather momentum. This can be used to produce intuitive user interface elements or convincing cartoon props that behave like their physical counterparts. Alternatively, it is sometimes desirable for animation to move forwards in distinct steps such as a segmented wheel that rotates such that the segments always appear in the same position. Similarly, controlling the rate of change of gradient interpolation can be used to produce different visual effects such as suggesting a concave or convex surface, or producing a striped effect. Easing functions provide a means to transform such values by taking an input progress value and producing a corresponding transformed output progress value. Given an input progress of 0.7, the easing function scales the value to produce an output progress of 0.52. Applying this easing function to an animation would cause it to progress more slowly at first but then gradually progress more quickly. 1.1. Value DefinitionsThis specification uses the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types. 2. Easing functionsAn easing function takes an input progress value and produces an output progress value. An easing function must be a pure function meaning that for a given set of inputs, it always produces the same output progress value. The input progress value is a real number in the range [-∞, ∞]. Typically, the input progress value is in the range [0, 1] but this may not be the case when easing functions are chained together. An example of when easing functions are chained together occurs in Web Animations [WEB-ANIMATIONS] where the output of the easing function specified on an animation effect may become the input to an easing function specified on one of the keyframes of a keyframe effect. In this scenario, the input to the easing function on the keyframe effect may be outside the range [0, 1]. The output progress value is a real number in the range [-∞, ∞]. Note: While CSS numbers have a theoretically infinite range (see CSS Values 4 § 5.1 Range Restrictions and Range Definition Notation) UAs will automatically clamp enormous numbers to a reasonable range. If easing functions are used outside of the CSS context, care must be taken to either correctly handle potential infinities (including those produced by merely very large values stored in a floating point number), or clamp the output progress value. Some types of easing functions also take an additional boolean before flag, which indicates the easing has not yet started, or is going in reverse and is past the finish. (Some easing functions can have multiple possible output progress values for a given input progress value, and generally favor the last one specified; this flag instead causes those easing functions to favor the first specified value before the animation has started.) This specification defines several types of easing functions: <easing-function> = <linear-easing-function> | <cubic-bezier-easing-function> | <step-easing-function> Tests2.1. Linear Easing Functions: linear, linear()A linear easing function is an easing function that interpolates linearly between its control points. Each control point is a pair of numbers, associating an input progress value to an output progress value. The shape of the curve follows the control points. Input progress values serve as x values of the curve, whilst the y values are the output progress values. A linear easing function has the following syntax: <linear-easing-function> = linear | <linear()> linear() = linear( [ <number> && <percentage>{0,2} ]# )
To canonicalize a linear() function’s control points,
perform the following:
After canonicalization, every control point has an input progress value, and the input progress values are monotonically non-decreasing along the list. Note: Serialization relies on whether or not an input progress value was originally supplied, so that information should be retained in the internal representation. It does not rely on whether a pair of control points were specified as two percentages on a single argument or as separate arguments. 2.1.1. SerializingThe linear keyword is serialized as itself.
To serialize a linear() function:
To serialize a linear() control point:
When serialized,
control points originally specified with two input progress values
are turned into two separate control points,
and the input progress values are in strictly ascending order.
For example:
2.1.2. OutputTo calculate linear easing output progress for a given linear easing function func, an input progress value inputProgress, and an optional before flag (defaulting to false), perform the following. It returns an output progress value.
2.1.3. Examples
linear() allows the definition of easing functions that interpolate linearly between a set of points.
For example, linear(0, 0.25, 1) produces an easing function that moves linearly from 0, to 0.25, then to 1:
By default, values are spread evenly between entries that don’t have an explicit "input".
Input values can be provided using a <percentage>.
For example, linear(0, 0.25 75%, 1) produces the following easing function, which spends 75% of the time transitioning from 0 to .25, then the last 25% transitioning from .25 to 1:
If two input values are provided for a single output,
it results in two points with the same output,
causing the easing to "pause" between the two inputs.
For example, linear(0, 0.25 25% 75%, 1) is equivalent to linear(0, 0.25 25%, 0.25 75%, 1), producing the following easing function:
If the input is outside the range provided,
the trajectory of the nearest two points is continued.
For example, here are the implicit values from the previous function:
A typical use of linear() is to provide many points to create the illusion of a curve.
For example, here’s how linear() could be used to create a reusable "bounce" easing function: :root The definition ends More points could be used to create a smoother result, which may be needed for slower animations. 2.2. Cubic Bézier Easing Functions: ease, ease-in, ease-out, ease-in-out, cubic-bezier()A cubic Bézier easing function is an easing function that interpolates smoothly from 0 to 1 using a cubic polynomial, influenced by two control points that the curve will approach but (usually) not actually reach. (The "endpoints" of the cubic Bézier are fixed at (0,0) and (1,1), respectively.) The shape of the curve is determined by the location of the control points P1 and P2. Input progress values serve as x values of the curve, whilst the y values are the output progress values. A cubic Bézier easing function has the following syntax: <cubic-bezier-easing-function> = ease | ease-in | ease-out | ease-in-out | <cubic-bezier()> cubic-bezier() = cubic-bezier( [ <number [0,1]>, <number> ]#{2} ) The meaning of each value is as follows:
The keyword values listed above are illustrated below.
2.2.1. SerializingThe ease-in, ease-out, ease-in-out, and ease keywords serialize as themselves.
To serialize a cubic-bezier() function:
2.2.2. Output
To calculate cubic Bézier easing output progress
for a given cubic Bézier easing function func
and an input progress value inputProgress,
perform the following.
It returns an output progress value.
2.3. Step Easing Functions: step-start, step-end, steps()A step easing function is an easing function that divides the input time into a specified number of intervals that are equal in length, and holds the output steady within each of those intervals. It is defined by a number of steps, and a step position. It has the following syntax: <step-easing-function> = step-start | step-end | <steps()> steps() = steps( <integer>, <step-position>?) <step-position> = jump-start | jump-end | jump-none | jump-both | start | end The meaning of each value is as follows:
The jump-* keywords values are illustrated below:
2.3.1. SerializingUnlike the other easing function keywords, step-start and step-end do not serialize as themselves. Instead, they serialize as "steps(1, start)" and "steps(1)", respectively.
To serialize a steps() functions:
2.3.2. Output
To calculate step easing output progress
for a given step easing function func,
an input progress value inputProgress,
and an optional before flag (defaulting to false),
perform the following.
It returns an output progress value.
Privacy ConsiderationsNo new privacy considerations have been reported on this specification. This specification does not directly introduce any new capabilities to the Web platform but rather provides common definitions that may be referenced by other specifications. Security ConsiderationsSpecifications referencing the features defined in this specification should consider that while easing functions most commonly take an input progress value in the range [0,1] and produce an output progress value in the range [0, 1], this is not always the case. Applications of easing functions should define the behavior for inputs and outputs outside this range to ensure they do not introduce new security considerations. 3. Changes3.1. Changes since the FPWD of 28 August 20243.2. Additions Since Level 1
4. AcknowledgementsThis specification is based on the CSS Transitions specification edited by L. David Baron, Dean Jackson, David Hyatt, and Chris Marrin. The editors would also like to thank Douglas Stockwell, Steve Block, Tab Atkins, Rachel Nabors, Martin Pitt, and the Animation at Work slack community for their feedback and contributions. | ||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |