rendx-ease 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/main.cjs +198 -0
- package/dist/main.d.cts +41 -0
- package/dist/main.d.ts +41 -0
- package/dist/main.js +136 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present wei.liang (https://github.com/weiliang0121)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/main.cjs
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/main.ts
|
|
21
|
+
var main_exports = {};
|
|
22
|
+
__export(main_exports, {
|
|
23
|
+
backIn: () => backIn,
|
|
24
|
+
backInOut: () => backInOut,
|
|
25
|
+
backOut: () => backOut,
|
|
26
|
+
bounceIn: () => bounceIn,
|
|
27
|
+
bounceInOut: () => bounceInOut,
|
|
28
|
+
bounceOut: () => bounceOut,
|
|
29
|
+
circIn: () => circIn,
|
|
30
|
+
circInOut: () => circInOut,
|
|
31
|
+
circOut: () => circOut,
|
|
32
|
+
cubicIn: () => cubicIn,
|
|
33
|
+
cubicInOut: () => cubicInOut,
|
|
34
|
+
cubicOut: () => cubicOut,
|
|
35
|
+
ease: () => ease,
|
|
36
|
+
easeMap: () => easeMap,
|
|
37
|
+
elasticIn: () => elasticIn,
|
|
38
|
+
elasticInOut: () => elasticInOut,
|
|
39
|
+
elasticOut: () => elasticOut,
|
|
40
|
+
expIn: () => expIn,
|
|
41
|
+
expInOut: () => expInOut,
|
|
42
|
+
expOut: () => expOut,
|
|
43
|
+
linear: () => linear,
|
|
44
|
+
polyIn: () => polyIn,
|
|
45
|
+
polyInOut: () => polyInOut,
|
|
46
|
+
polyOut: () => polyOut,
|
|
47
|
+
quadIn: () => quadIn,
|
|
48
|
+
quadInOut: () => quadInOut,
|
|
49
|
+
quadOut: () => quadOut,
|
|
50
|
+
quartIn: () => quartIn,
|
|
51
|
+
quartInOut: () => quartInOut,
|
|
52
|
+
quartOut: () => quartOut,
|
|
53
|
+
quintIn: () => quintIn,
|
|
54
|
+
quintInOut: () => quintInOut,
|
|
55
|
+
quintOut: () => quintOut,
|
|
56
|
+
sineIn: () => sineIn,
|
|
57
|
+
sineInOut: () => sineInOut,
|
|
58
|
+
sineOut: () => sineOut
|
|
59
|
+
});
|
|
60
|
+
module.exports = __toCommonJS(main_exports);
|
|
61
|
+
|
|
62
|
+
// src/ease.ts
|
|
63
|
+
var { pow, sqrt, sin, cos, PI } = Math;
|
|
64
|
+
var PI2 = PI / 2;
|
|
65
|
+
var linear = (t) => t;
|
|
66
|
+
var polyIn = (n = 3) => (t) => pow(t, n);
|
|
67
|
+
var polyOut = (n = 3) => (t) => 1 - pow(1 - t, n);
|
|
68
|
+
var polyInOut = (n = 3) => {
|
|
69
|
+
const c = pow(2, n - 1);
|
|
70
|
+
return (t) => t < 0.5 ? c * pow(t, n) : 1 - pow(-2 * t + 2, n) / 2;
|
|
71
|
+
};
|
|
72
|
+
var quadIn = (t) => t * t;
|
|
73
|
+
var quadOut = (t) => t * (2 - t);
|
|
74
|
+
var quadInOut = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
75
|
+
var cubicIn = (t) => t * t * t;
|
|
76
|
+
var cubicOut = (t) => --t * t * t + 1;
|
|
77
|
+
var cubicInOut = (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
|
78
|
+
var quartIn = (t) => t * t * t * t;
|
|
79
|
+
var quartOut = (t) => 1 - --t * t * t * t;
|
|
80
|
+
var quartInOut = (t) => t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
|
81
|
+
var quintIn = (t) => t * t * t * t * t;
|
|
82
|
+
var quintOut = (t) => 1 + --t * t * t * t * t;
|
|
83
|
+
var quintInOut = (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
|
84
|
+
var sineIn = (t) => 1 - cos(t * PI2);
|
|
85
|
+
var sineOut = (t) => sin(t * PI2);
|
|
86
|
+
var sineInOut = (t) => -(cos(PI * t) - 1) / 2;
|
|
87
|
+
var expIn = (t) => t === 0 ? 0 : pow(2, 10 * (t - 1));
|
|
88
|
+
var expOut = (t) => t === 1 ? 1 : 1 - pow(2, -10 * t);
|
|
89
|
+
var expInOut = (t) => {
|
|
90
|
+
if (t === 0 || t === 1) return t;
|
|
91
|
+
return t < 0.5 ? pow(2, 20 * t - 10) / 2 : (2 - pow(2, -20 * t + 10)) / 2;
|
|
92
|
+
};
|
|
93
|
+
var circIn = (t) => 1 - sqrt(1 - t * t);
|
|
94
|
+
var circOut = (t) => sqrt(1 - --t * t);
|
|
95
|
+
var circInOut = (t) => t < 0.5 ? (1 - sqrt(1 - 4 * t * t)) / 2 : (sqrt(1 - (-2 * t + 2) * (-2 * t + 2)) + 1) / 2;
|
|
96
|
+
var C1 = 1.70158;
|
|
97
|
+
var C2 = C1 + 1;
|
|
98
|
+
var C3 = C1 * 1.525;
|
|
99
|
+
var backIn = (t) => C2 * t * t * t - C1 * t * t;
|
|
100
|
+
var backOut = (t) => 1 + C2 * --t * t * t + C1 * t * t;
|
|
101
|
+
var backInOut = (t) => t < 0.5 ? pow(2 * t, 2) * ((C3 + 1) * 2 * t - C3) / 2 : (pow(2 * t - 2, 2) * ((C3 + 1) * (2 * t - 2) + C3) + 2) / 2;
|
|
102
|
+
var E1 = 2 * PI / 3;
|
|
103
|
+
var E2 = 2 * PI / 4.5;
|
|
104
|
+
var elasticIn = (t) => {
|
|
105
|
+
if (t === 0 || t === 1) return t;
|
|
106
|
+
return -pow(2, 10 * t - 10) * sin((10 * t - 10.75) * E1);
|
|
107
|
+
};
|
|
108
|
+
var elasticOut = (t) => {
|
|
109
|
+
if (t === 0 || t === 1) return t;
|
|
110
|
+
return pow(2, -10 * t) * sin((10 * t - 0.75) * E1) + 1;
|
|
111
|
+
};
|
|
112
|
+
var elasticInOut = (t) => {
|
|
113
|
+
if (t === 0 || t === 1) return t;
|
|
114
|
+
return t < 0.5 ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * E2)) / 2 : pow(2, -20 * t + 10) * sin((20 * t - 11.125) * E2) / 2 + 1;
|
|
115
|
+
};
|
|
116
|
+
var N = 7.5625;
|
|
117
|
+
var D = 2.75;
|
|
118
|
+
var bounceOut = (t) => {
|
|
119
|
+
if (t < 1 / D) return N * t * t;
|
|
120
|
+
if (t < 2 / D) return N * (t -= 1.5 / D) * t + 0.75;
|
|
121
|
+
if (t < 2.5 / D) return N * (t -= 2.25 / D) * t + 0.9375;
|
|
122
|
+
return N * (t -= 2.625 / D) * t + 0.984375;
|
|
123
|
+
};
|
|
124
|
+
var bounceIn = (t) => 1 - bounceOut(1 - t);
|
|
125
|
+
var bounceInOut = (t) => t < 0.5 ? (1 - bounceOut(1 - 2 * t)) / 2 : (1 + bounceOut(2 * t - 1)) / 2;
|
|
126
|
+
var easeMap = {
|
|
127
|
+
linear,
|
|
128
|
+
inQuad: quadIn,
|
|
129
|
+
outQuad: quadOut,
|
|
130
|
+
inOutQuad: quadInOut,
|
|
131
|
+
inCubic: cubicIn,
|
|
132
|
+
outCubic: cubicOut,
|
|
133
|
+
inOutCubic: cubicInOut,
|
|
134
|
+
inQuart: quartIn,
|
|
135
|
+
outQuart: quartOut,
|
|
136
|
+
inOutQuart: quartInOut,
|
|
137
|
+
inQuint: quintIn,
|
|
138
|
+
outQuint: quintOut,
|
|
139
|
+
inOutQuint: quintInOut,
|
|
140
|
+
inSine: sineIn,
|
|
141
|
+
outSine: sineOut,
|
|
142
|
+
inOutSine: sineInOut,
|
|
143
|
+
inExp: expIn,
|
|
144
|
+
outExp: expOut,
|
|
145
|
+
inOutExp: expInOut,
|
|
146
|
+
inCirc: circIn,
|
|
147
|
+
outCirc: circOut,
|
|
148
|
+
inOutCirc: circInOut,
|
|
149
|
+
inBack: backIn,
|
|
150
|
+
outBack: backOut,
|
|
151
|
+
inOutBack: backInOut,
|
|
152
|
+
inElastic: elasticIn,
|
|
153
|
+
outElastic: elasticOut,
|
|
154
|
+
inOutElastic: elasticInOut,
|
|
155
|
+
inBounce: bounceIn,
|
|
156
|
+
outBounce: bounceOut,
|
|
157
|
+
inOutBounce: bounceInOut
|
|
158
|
+
};
|
|
159
|
+
var ease = (name) => easeMap[name] ?? linear;
|
|
160
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
+
0 && (module.exports = {
|
|
162
|
+
backIn,
|
|
163
|
+
backInOut,
|
|
164
|
+
backOut,
|
|
165
|
+
bounceIn,
|
|
166
|
+
bounceInOut,
|
|
167
|
+
bounceOut,
|
|
168
|
+
circIn,
|
|
169
|
+
circInOut,
|
|
170
|
+
circOut,
|
|
171
|
+
cubicIn,
|
|
172
|
+
cubicInOut,
|
|
173
|
+
cubicOut,
|
|
174
|
+
ease,
|
|
175
|
+
easeMap,
|
|
176
|
+
elasticIn,
|
|
177
|
+
elasticInOut,
|
|
178
|
+
elasticOut,
|
|
179
|
+
expIn,
|
|
180
|
+
expInOut,
|
|
181
|
+
expOut,
|
|
182
|
+
linear,
|
|
183
|
+
polyIn,
|
|
184
|
+
polyInOut,
|
|
185
|
+
polyOut,
|
|
186
|
+
quadIn,
|
|
187
|
+
quadInOut,
|
|
188
|
+
quadOut,
|
|
189
|
+
quartIn,
|
|
190
|
+
quartInOut,
|
|
191
|
+
quartOut,
|
|
192
|
+
quintIn,
|
|
193
|
+
quintInOut,
|
|
194
|
+
quintOut,
|
|
195
|
+
sineIn,
|
|
196
|
+
sineInOut,
|
|
197
|
+
sineOut
|
|
198
|
+
});
|
package/dist/main.d.cts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** 缓动函数类型 */
|
|
2
|
+
type Ease = (t: number) => number;
|
|
3
|
+
declare const linear: Ease;
|
|
4
|
+
declare const polyIn: (n?: number) => Ease;
|
|
5
|
+
declare const polyOut: (n?: number) => Ease;
|
|
6
|
+
declare const polyInOut: (n?: number) => Ease;
|
|
7
|
+
declare const quadIn: Ease;
|
|
8
|
+
declare const quadOut: Ease;
|
|
9
|
+
declare const quadInOut: Ease;
|
|
10
|
+
declare const cubicIn: Ease;
|
|
11
|
+
declare const cubicOut: Ease;
|
|
12
|
+
declare const cubicInOut: Ease;
|
|
13
|
+
declare const quartIn: Ease;
|
|
14
|
+
declare const quartOut: Ease;
|
|
15
|
+
declare const quartInOut: Ease;
|
|
16
|
+
declare const quintIn: Ease;
|
|
17
|
+
declare const quintOut: Ease;
|
|
18
|
+
declare const quintInOut: Ease;
|
|
19
|
+
declare const sineIn: Ease;
|
|
20
|
+
declare const sineOut: Ease;
|
|
21
|
+
declare const sineInOut: Ease;
|
|
22
|
+
declare const expIn: Ease;
|
|
23
|
+
declare const expOut: Ease;
|
|
24
|
+
declare const expInOut: Ease;
|
|
25
|
+
declare const circIn: Ease;
|
|
26
|
+
declare const circOut: Ease;
|
|
27
|
+
declare const circInOut: Ease;
|
|
28
|
+
declare const backIn: Ease;
|
|
29
|
+
declare const backOut: Ease;
|
|
30
|
+
declare const backInOut: Ease;
|
|
31
|
+
declare const elasticIn: Ease;
|
|
32
|
+
declare const elasticOut: Ease;
|
|
33
|
+
declare const elasticInOut: Ease;
|
|
34
|
+
declare const bounceOut: Ease;
|
|
35
|
+
declare const bounceIn: Ease;
|
|
36
|
+
declare const bounceInOut: Ease;
|
|
37
|
+
declare const easeMap: Record<string, Ease>;
|
|
38
|
+
/** 按名称查找缓动函数,未找到时返回 linear */
|
|
39
|
+
declare const ease: (name: string) => Ease;
|
|
40
|
+
|
|
41
|
+
export { type Ease, backIn, backInOut, backOut, bounceIn, bounceInOut, bounceOut, circIn, circInOut, circOut, cubicIn, cubicInOut, cubicOut, ease, easeMap, elasticIn, elasticInOut, elasticOut, expIn, expInOut, expOut, linear, polyIn, polyInOut, polyOut, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, sineIn, sineInOut, sineOut };
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** 缓动函数类型 */
|
|
2
|
+
type Ease = (t: number) => number;
|
|
3
|
+
declare const linear: Ease;
|
|
4
|
+
declare const polyIn: (n?: number) => Ease;
|
|
5
|
+
declare const polyOut: (n?: number) => Ease;
|
|
6
|
+
declare const polyInOut: (n?: number) => Ease;
|
|
7
|
+
declare const quadIn: Ease;
|
|
8
|
+
declare const quadOut: Ease;
|
|
9
|
+
declare const quadInOut: Ease;
|
|
10
|
+
declare const cubicIn: Ease;
|
|
11
|
+
declare const cubicOut: Ease;
|
|
12
|
+
declare const cubicInOut: Ease;
|
|
13
|
+
declare const quartIn: Ease;
|
|
14
|
+
declare const quartOut: Ease;
|
|
15
|
+
declare const quartInOut: Ease;
|
|
16
|
+
declare const quintIn: Ease;
|
|
17
|
+
declare const quintOut: Ease;
|
|
18
|
+
declare const quintInOut: Ease;
|
|
19
|
+
declare const sineIn: Ease;
|
|
20
|
+
declare const sineOut: Ease;
|
|
21
|
+
declare const sineInOut: Ease;
|
|
22
|
+
declare const expIn: Ease;
|
|
23
|
+
declare const expOut: Ease;
|
|
24
|
+
declare const expInOut: Ease;
|
|
25
|
+
declare const circIn: Ease;
|
|
26
|
+
declare const circOut: Ease;
|
|
27
|
+
declare const circInOut: Ease;
|
|
28
|
+
declare const backIn: Ease;
|
|
29
|
+
declare const backOut: Ease;
|
|
30
|
+
declare const backInOut: Ease;
|
|
31
|
+
declare const elasticIn: Ease;
|
|
32
|
+
declare const elasticOut: Ease;
|
|
33
|
+
declare const elasticInOut: Ease;
|
|
34
|
+
declare const bounceOut: Ease;
|
|
35
|
+
declare const bounceIn: Ease;
|
|
36
|
+
declare const bounceInOut: Ease;
|
|
37
|
+
declare const easeMap: Record<string, Ease>;
|
|
38
|
+
/** 按名称查找缓动函数,未找到时返回 linear */
|
|
39
|
+
declare const ease: (name: string) => Ease;
|
|
40
|
+
|
|
41
|
+
export { type Ease, backIn, backInOut, backOut, bounceIn, bounceInOut, bounceOut, circIn, circInOut, circOut, cubicIn, cubicInOut, cubicOut, ease, easeMap, elasticIn, elasticInOut, elasticOut, expIn, expInOut, expOut, linear, polyIn, polyInOut, polyOut, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, sineIn, sineInOut, sineOut };
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/ease.ts
|
|
2
|
+
var { pow, sqrt, sin, cos, PI } = Math;
|
|
3
|
+
var PI2 = PI / 2;
|
|
4
|
+
var linear = (t) => t;
|
|
5
|
+
var polyIn = (n = 3) => (t) => pow(t, n);
|
|
6
|
+
var polyOut = (n = 3) => (t) => 1 - pow(1 - t, n);
|
|
7
|
+
var polyInOut = (n = 3) => {
|
|
8
|
+
const c = pow(2, n - 1);
|
|
9
|
+
return (t) => t < 0.5 ? c * pow(t, n) : 1 - pow(-2 * t + 2, n) / 2;
|
|
10
|
+
};
|
|
11
|
+
var quadIn = (t) => t * t;
|
|
12
|
+
var quadOut = (t) => t * (2 - t);
|
|
13
|
+
var quadInOut = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
14
|
+
var cubicIn = (t) => t * t * t;
|
|
15
|
+
var cubicOut = (t) => --t * t * t + 1;
|
|
16
|
+
var cubicInOut = (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
|
17
|
+
var quartIn = (t) => t * t * t * t;
|
|
18
|
+
var quartOut = (t) => 1 - --t * t * t * t;
|
|
19
|
+
var quartInOut = (t) => t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
|
20
|
+
var quintIn = (t) => t * t * t * t * t;
|
|
21
|
+
var quintOut = (t) => 1 + --t * t * t * t * t;
|
|
22
|
+
var quintInOut = (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
|
23
|
+
var sineIn = (t) => 1 - cos(t * PI2);
|
|
24
|
+
var sineOut = (t) => sin(t * PI2);
|
|
25
|
+
var sineInOut = (t) => -(cos(PI * t) - 1) / 2;
|
|
26
|
+
var expIn = (t) => t === 0 ? 0 : pow(2, 10 * (t - 1));
|
|
27
|
+
var expOut = (t) => t === 1 ? 1 : 1 - pow(2, -10 * t);
|
|
28
|
+
var expInOut = (t) => {
|
|
29
|
+
if (t === 0 || t === 1) return t;
|
|
30
|
+
return t < 0.5 ? pow(2, 20 * t - 10) / 2 : (2 - pow(2, -20 * t + 10)) / 2;
|
|
31
|
+
};
|
|
32
|
+
var circIn = (t) => 1 - sqrt(1 - t * t);
|
|
33
|
+
var circOut = (t) => sqrt(1 - --t * t);
|
|
34
|
+
var circInOut = (t) => t < 0.5 ? (1 - sqrt(1 - 4 * t * t)) / 2 : (sqrt(1 - (-2 * t + 2) * (-2 * t + 2)) + 1) / 2;
|
|
35
|
+
var C1 = 1.70158;
|
|
36
|
+
var C2 = C1 + 1;
|
|
37
|
+
var C3 = C1 * 1.525;
|
|
38
|
+
var backIn = (t) => C2 * t * t * t - C1 * t * t;
|
|
39
|
+
var backOut = (t) => 1 + C2 * --t * t * t + C1 * t * t;
|
|
40
|
+
var backInOut = (t) => t < 0.5 ? pow(2 * t, 2) * ((C3 + 1) * 2 * t - C3) / 2 : (pow(2 * t - 2, 2) * ((C3 + 1) * (2 * t - 2) + C3) + 2) / 2;
|
|
41
|
+
var E1 = 2 * PI / 3;
|
|
42
|
+
var E2 = 2 * PI / 4.5;
|
|
43
|
+
var elasticIn = (t) => {
|
|
44
|
+
if (t === 0 || t === 1) return t;
|
|
45
|
+
return -pow(2, 10 * t - 10) * sin((10 * t - 10.75) * E1);
|
|
46
|
+
};
|
|
47
|
+
var elasticOut = (t) => {
|
|
48
|
+
if (t === 0 || t === 1) return t;
|
|
49
|
+
return pow(2, -10 * t) * sin((10 * t - 0.75) * E1) + 1;
|
|
50
|
+
};
|
|
51
|
+
var elasticInOut = (t) => {
|
|
52
|
+
if (t === 0 || t === 1) return t;
|
|
53
|
+
return t < 0.5 ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * E2)) / 2 : pow(2, -20 * t + 10) * sin((20 * t - 11.125) * E2) / 2 + 1;
|
|
54
|
+
};
|
|
55
|
+
var N = 7.5625;
|
|
56
|
+
var D = 2.75;
|
|
57
|
+
var bounceOut = (t) => {
|
|
58
|
+
if (t < 1 / D) return N * t * t;
|
|
59
|
+
if (t < 2 / D) return N * (t -= 1.5 / D) * t + 0.75;
|
|
60
|
+
if (t < 2.5 / D) return N * (t -= 2.25 / D) * t + 0.9375;
|
|
61
|
+
return N * (t -= 2.625 / D) * t + 0.984375;
|
|
62
|
+
};
|
|
63
|
+
var bounceIn = (t) => 1 - bounceOut(1 - t);
|
|
64
|
+
var bounceInOut = (t) => t < 0.5 ? (1 - bounceOut(1 - 2 * t)) / 2 : (1 + bounceOut(2 * t - 1)) / 2;
|
|
65
|
+
var easeMap = {
|
|
66
|
+
linear,
|
|
67
|
+
inQuad: quadIn,
|
|
68
|
+
outQuad: quadOut,
|
|
69
|
+
inOutQuad: quadInOut,
|
|
70
|
+
inCubic: cubicIn,
|
|
71
|
+
outCubic: cubicOut,
|
|
72
|
+
inOutCubic: cubicInOut,
|
|
73
|
+
inQuart: quartIn,
|
|
74
|
+
outQuart: quartOut,
|
|
75
|
+
inOutQuart: quartInOut,
|
|
76
|
+
inQuint: quintIn,
|
|
77
|
+
outQuint: quintOut,
|
|
78
|
+
inOutQuint: quintInOut,
|
|
79
|
+
inSine: sineIn,
|
|
80
|
+
outSine: sineOut,
|
|
81
|
+
inOutSine: sineInOut,
|
|
82
|
+
inExp: expIn,
|
|
83
|
+
outExp: expOut,
|
|
84
|
+
inOutExp: expInOut,
|
|
85
|
+
inCirc: circIn,
|
|
86
|
+
outCirc: circOut,
|
|
87
|
+
inOutCirc: circInOut,
|
|
88
|
+
inBack: backIn,
|
|
89
|
+
outBack: backOut,
|
|
90
|
+
inOutBack: backInOut,
|
|
91
|
+
inElastic: elasticIn,
|
|
92
|
+
outElastic: elasticOut,
|
|
93
|
+
inOutElastic: elasticInOut,
|
|
94
|
+
inBounce: bounceIn,
|
|
95
|
+
outBounce: bounceOut,
|
|
96
|
+
inOutBounce: bounceInOut
|
|
97
|
+
};
|
|
98
|
+
var ease = (name) => easeMap[name] ?? linear;
|
|
99
|
+
export {
|
|
100
|
+
backIn,
|
|
101
|
+
backInOut,
|
|
102
|
+
backOut,
|
|
103
|
+
bounceIn,
|
|
104
|
+
bounceInOut,
|
|
105
|
+
bounceOut,
|
|
106
|
+
circIn,
|
|
107
|
+
circInOut,
|
|
108
|
+
circOut,
|
|
109
|
+
cubicIn,
|
|
110
|
+
cubicInOut,
|
|
111
|
+
cubicOut,
|
|
112
|
+
ease,
|
|
113
|
+
easeMap,
|
|
114
|
+
elasticIn,
|
|
115
|
+
elasticInOut,
|
|
116
|
+
elasticOut,
|
|
117
|
+
expIn,
|
|
118
|
+
expInOut,
|
|
119
|
+
expOut,
|
|
120
|
+
linear,
|
|
121
|
+
polyIn,
|
|
122
|
+
polyInOut,
|
|
123
|
+
polyOut,
|
|
124
|
+
quadIn,
|
|
125
|
+
quadInOut,
|
|
126
|
+
quadOut,
|
|
127
|
+
quartIn,
|
|
128
|
+
quartInOut,
|
|
129
|
+
quartOut,
|
|
130
|
+
quintIn,
|
|
131
|
+
quintInOut,
|
|
132
|
+
quintOut,
|
|
133
|
+
sineIn,
|
|
134
|
+
sineInOut,
|
|
135
|
+
sineOut
|
|
136
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rendx-ease",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Easing functions collection (33 built-in)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "wei.liang (https://github.com/weiliang0121)",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"rendx",
|
|
10
|
+
"2d",
|
|
11
|
+
"canvas",
|
|
12
|
+
"rendering",
|
|
13
|
+
"visualization",
|
|
14
|
+
"scene-graph"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://weiliang0121.github.io/rendx/",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/weiliang0121/rendx.git",
|
|
20
|
+
"directory": "packages/ease"
|
|
21
|
+
},
|
|
22
|
+
"main": "dist/main.cjs",
|
|
23
|
+
"module": "dist/main.js",
|
|
24
|
+
"types": "dist/main.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/main.d.ts",
|
|
28
|
+
"import": "./dist/main.js",
|
|
29
|
+
"require": "./dist/main.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch"
|
|
42
|
+
}
|
|
43
|
+
}
|