1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.easing = {
|
---|
4 | // No easing, no acceleration
|
---|
5 | linear: function (t) { return t; },
|
---|
6 | // Accelerates fast, then slows quickly towards end.
|
---|
7 | quadratic: function (t) { return t * (-(t * t) * t + 4 * t * t - 6 * t + 4); },
|
---|
8 | // Overshoots over 1 and then returns to 1 towards end.
|
---|
9 | cubic: function (t) { return t * (4 * t * t - 9 * t + 6); },
|
---|
10 | // Overshoots over 1 multiple times - wiggles around 1.
|
---|
11 | elastic: function (t) { return t * (33 * t * t * t * t - 106 * t * t * t + 126 * t * t - 67 * t + 15); },
|
---|
12 | // Accelerating from zero velocity
|
---|
13 | inQuad: function (t) { return t * t; },
|
---|
14 | // Decelerating to zero velocity
|
---|
15 | outQuad: function (t) { return t * (2 - t); },
|
---|
16 | // Acceleration until halfway, then deceleration
|
---|
17 | inOutQuad: function (t) { return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t; },
|
---|
18 | // Accelerating from zero velocity
|
---|
19 | inCubic: function (t) { return t * t * t; },
|
---|
20 | // Decelerating to zero velocity
|
---|
21 | outCubic: function (t) { return (--t) * t * t + 1; },
|
---|
22 | // Acceleration until halfway, then deceleration
|
---|
23 | inOutCubic: function (t) { return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; },
|
---|
24 | // Accelerating from zero velocity
|
---|
25 | inQuart: function (t) { return t * t * t * t; },
|
---|
26 | // Decelerating to zero velocity
|
---|
27 | outQuart: function (t) { return 1 - (--t) * t * t * t; },
|
---|
28 | // Acceleration until halfway, then deceleration
|
---|
29 | inOutQuart: function (t) { return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t; },
|
---|
30 | // Accelerating from zero velocity
|
---|
31 | inQuint: function (t) { return t * t * t * t * t; },
|
---|
32 | // Decelerating to zero velocity
|
---|
33 | outQuint: function (t) { return 1 + (--t) * t * t * t * t; },
|
---|
34 | // Acceleration until halfway, then deceleration
|
---|
35 | inOutQuint: function (t) { return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t; },
|
---|
36 | // Accelerating from zero velocity
|
---|
37 | inSine: function (t) { return -Math.cos(t * (Math.PI / 2)) + 1; },
|
---|
38 | // Decelerating to zero velocity
|
---|
39 | outSine: function (t) { return Math.sin(t * (Math.PI / 2)); },
|
---|
40 | // Accelerating until halfway, then decelerating
|
---|
41 | inOutSine: function (t) { return -(Math.cos(Math.PI * t) - 1) / 2; },
|
---|
42 | // Exponential accelerating from zero velocity
|
---|
43 | inExpo: function (t) { return Math.pow(2, 10 * (t - 1)); },
|
---|
44 | // Exponential decelerating to zero velocity
|
---|
45 | outExpo: function (t) { return -Math.pow(2, -10 * t) + 1; },
|
---|
46 | // Exponential accelerating until halfway, then decelerating
|
---|
47 | inOutExpo: function (t) {
|
---|
48 | t /= .5;
|
---|
49 | if (t < 1)
|
---|
50 | return Math.pow(2, 10 * (t - 1)) / 2;
|
---|
51 | t--;
|
---|
52 | return (-Math.pow(2, -10 * t) + 2) / 2;
|
---|
53 | },
|
---|
54 | // Circular accelerating from zero velocity
|
---|
55 | inCirc: function (t) { return -Math.sqrt(1 - t * t) + 1; },
|
---|
56 | // Circular decelerating to zero velocity Moves VERY fast at the beginning and
|
---|
57 | // then quickly slows down in the middle. This tween can actually be used
|
---|
58 | // in continuous transitions where target value changes all the time,
|
---|
59 | // because of the very quick start, it hides the jitter between target value changes.
|
---|
60 | outCirc: function (t) { return Math.sqrt(1 - (t = t - 1) * t); },
|
---|
61 | // Circular acceleration until halfway, then deceleration
|
---|
62 | inOutCirc: function (t) {
|
---|
63 | t /= .5;
|
---|
64 | if (t < 1)
|
---|
65 | return -(Math.sqrt(1 - t * t) - 1) / 2;
|
---|
66 | t -= 2;
|
---|
67 | return (Math.sqrt(1 - t * t) + 1) / 2;
|
---|
68 | }
|
---|
69 | };
|
---|