1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.Easing = void 0;
|
5 | const bezier_1 = require("./bezier");
|
6 | class Easing {
|
7 | static step0(n) {
|
8 | return n > 0 ? 1 : 0;
|
9 | }
|
10 | static step1(n) {
|
11 | return n >= 1 ? 1 : 0;
|
12 | }
|
13 | static linear(t) {
|
14 | return t;
|
15 | }
|
16 | static ease(t) {
|
17 | return Easing.bezier(0.42, 0, 1, 1)(t);
|
18 | }
|
19 | static quad(t) {
|
20 | return t * t;
|
21 | }
|
22 | static cubic(t) {
|
23 | return t * t * t;
|
24 | }
|
25 | static poly(n) {
|
26 | return (t) => t ** n;
|
27 | }
|
28 | static sin(t) {
|
29 | return 1 - Math.cos((t * Math.PI) / 2);
|
30 | }
|
31 | static circle(t) {
|
32 | return 1 - Math.sqrt(1 - t * t);
|
33 | }
|
34 | static exp(t) {
|
35 | return 2 ** (10 * (t - 1));
|
36 | }
|
37 | static elastic(bounciness = 1) {
|
38 | const p = bounciness * Math.PI;
|
39 | return (t) => 1 - Math.cos((t * Math.PI) / 2) ** 3 * Math.cos(t * p);
|
40 | }
|
41 | static back(s = 1.70158) {
|
42 | return (t) => t * t * ((s + 1) * t - s);
|
43 | }
|
44 | static bounce(t) {
|
45 | if (t < 1 / 2.75) {
|
46 | return 7.5625 * t * t;
|
47 | }
|
48 | if (t < 2 / 2.75) {
|
49 | const t2_ = t - 1.5 / 2.75;
|
50 | return 7.5625 * t2_ * t2_ + 0.75;
|
51 | }
|
52 | if (t < 2.5 / 2.75) {
|
53 | const t2_ = t - 2.25 / 2.75;
|
54 | return 7.5625 * t2_ * t2_ + 0.9375;
|
55 | }
|
56 | const t2 = t - 2.625 / 2.75;
|
57 | return 7.5625 * t2 * t2 + 0.984375;
|
58 | }
|
59 | static bezier(x1, y1, x2, y2) {
|
60 | return (0, bezier_1.bezier)(x1, y1, x2, y2);
|
61 | }
|
62 | static in(easing) {
|
63 | return easing;
|
64 | }
|
65 | static out(easing) {
|
66 | return (t) => 1 - easing(1 - t);
|
67 | }
|
68 | static inOut(easing) {
|
69 | return (t) => {
|
70 | if (t < 0.5) {
|
71 | return easing(t * 2) / 2;
|
72 | }
|
73 | return 1 - easing((1 - t) * 2) / 2;
|
74 | };
|
75 | }
|
76 | }
|
77 | exports.Easing = Easing;
|
78 |
|
\ | No newline at end of file |