Timing functions for transitions.
This module is based on the article by Gaëtan Renaudeau, with code released under an MIT license.
Members
(static, constant) ease
An easing timing function.
- Source:
(static, constant) easeIn
An ease-in timing function.
- Source:
(static, constant) easeInOut
A timing function with ease-in and ease-out.
- Source:
(static, constant) easeOut
An ease-out timing function.
- Source:
(static, constant) linear
A linear timing function.
- Source:
(static, constant) stepEnd
A single final step timing function.
- Source:
(static, constant) stepStart
A single immediate step timing function.
- Source:
Methods
(static) makeBezier(x1, y1, x2, y2) → {function}
Create a Bézier curve with the given control points.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The X coordinate of the first control point. |
y1 |
number | The Y coordinate of the first control point. |
x2 |
number | The X coordinate of the second control point. |
y2 |
number | The Y coordinate of the second control point. |
- Source:
Returns:
- A function that takes a coordinates X and computes the Y coordinate of the corresponding point of the Bézier curve.
- Type
- function
(static) makeSteps(n, start) → {function}
Create a staircase function.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | The number of steps. |
start |
boolean | Step at the beginning or at the end of each interval? |
- Source:
Returns:
- A function that takes a coordinates X and computes the Y coordinate of the corresponding point of the step function.
- Type
- function
(static) stepMiddle(t) → {number}
A middle step timing function.
Parameters:
Name | Type | Description |
---|---|---|
t |
number | The current time, between 0 and 1. |
- Source:
Returns:
- The actual progress, between 0 and 1.
- Type
- number
(inner) A(xy1, xy2) → {number}
Helper function to compute a Bézier curve.
Parameters:
Name | Type | Description |
---|---|---|
xy1 |
number | X or Y coordinate of the first control point. |
xy2 |
number | X or Y coordinate of the second control point. |
- Source:
Returns:
- A linear combination of the arguments.
- Type
- number
(inner) B(xy1, xy2) → {number}
Helper function to compute a Bézier curve.
Parameters:
Name | Type | Description |
---|---|---|
xy1 |
number | X or Y coordinate of the first control point. |
xy2 |
number | X or Y coordinate of the second control point. |
- Source:
Returns:
- A linear combination of the arguments.
- Type
- number
(inner) bezier(t, a, b, c) → {number}
Compute a coordinate of a point of the Bézier curve.
Parameters:
Name | Type | Description |
---|---|---|
t |
number | The location of the point along the curve. |
a |
number | The output of function |
b |
number | The output of function |
c |
number | The output of function |
- Source:
Returns:
- The X or Y coordinate of a point of the Bézier curve.
- Type
- number
(inner) bezierSlope(t, a, b, c) → {number}
Compute the derivative of a coordinate at a point of the Bézier curve.
Parameters:
Name | Type | Description |
---|---|---|
t |
number | The location of the point along the curve. |
a |
number | The output of function |
b |
number | The output of function |
c |
number | The output of function |
- Source:
Returns:
- The derivative dX/dt or dY/dt of a coordinate at a point of the Bézier curve.
- Type
- number
(inner) C(xy1) → {number}
Helper function to compute a Bézier curve.
Parameters:
Name | Type | Description |
---|---|---|
xy1 |
number | X or Y coordinate of the first control point. |
- Source:
Returns:
- A linear combination of the arguments.
- Type
- number