@studiometa/js-toolkit 2.2.0 → 2.2.1
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/package.json +1 -1
- package/utils/css/animate.d.ts +5 -7
- package/utils/math/createEases.cjs +32 -0
- package/utils/math/createEases.d.ts +18 -0
- package/utils/math/createEases.js +10 -0
- package/utils/math/ease.cjs +15 -22
- package/utils/math/ease.d.ts +16 -33
- package/utils/math/ease.js +1 -8
- package/utils/math/index.cjs +1 -0
- package/utils/math/index.d.ts +1 -0
- package/utils/math/index.js +1 -0
package/package.json
CHANGED
package/utils/css/animate.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('./transform.js').TransformProps} TransformProps
|
|
3
|
-
* @typedef {import('../math/ease.js').EasingFunction} EasingFn
|
|
4
3
|
* @typedef {[number, number, number, number]} BezierCurve
|
|
5
4
|
* @typedef {{
|
|
6
5
|
* duration?: number;
|
|
7
|
-
* easing?:
|
|
6
|
+
* easing?: import('../math/createEases.js').EasingFunction|BezierCurve;
|
|
8
7
|
* onProgress?: (progress: number, easedProgress: number) => void;
|
|
9
8
|
* onFinish?: (progress: number, easedProgress: number) => void;
|
|
10
9
|
* }} Options
|
|
11
10
|
* @typedef {TransformProps & {
|
|
12
11
|
* opacity?: number;
|
|
13
12
|
* transformOrigin?: string;
|
|
14
|
-
* easing?:
|
|
13
|
+
* easing?: import('../math/createEases.js').EasingFunction|BezierCurve;
|
|
15
14
|
* offset?: number;
|
|
16
15
|
* }} Keyframe
|
|
17
16
|
* @typedef {Keyframe & {
|
|
18
|
-
* easing:
|
|
17
|
+
* easing: import('../math/createEases.js').EasingFunction;
|
|
19
18
|
* offset: number;
|
|
20
19
|
* }} NormalizedKeyframe
|
|
21
20
|
* @typedef {{
|
|
@@ -35,17 +34,16 @@
|
|
|
35
34
|
*/
|
|
36
35
|
export function animate(element: HTMLElement, keyframes: Keyframe[], options?: Options): Animate;
|
|
37
36
|
export type TransformProps = import('./transform.js').TransformProps;
|
|
38
|
-
export type EasingFn = import('../math/ease.js').EasingFunction;
|
|
39
37
|
export type BezierCurve = [number, number, number, number];
|
|
40
38
|
export type Options = Options;
|
|
41
39
|
export type Keyframe = TransformProps & {
|
|
42
40
|
opacity?: number;
|
|
43
41
|
transformOrigin?: string;
|
|
44
|
-
easing?:
|
|
42
|
+
easing?: import('../math/createEases.js').EasingFunction | [number, number, number, number];
|
|
45
43
|
offset?: number;
|
|
46
44
|
};
|
|
47
45
|
export type NormalizedKeyframe = Keyframe & {
|
|
48
|
-
easing:
|
|
46
|
+
easing: import('../math/createEases.js').EasingFunction;
|
|
49
47
|
offset: number;
|
|
50
48
|
};
|
|
51
49
|
export type Animate = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/math/createEases.js
|
|
20
|
+
var createEases_exports = {};
|
|
21
|
+
__export(createEases_exports, {
|
|
22
|
+
createEaseInOut: () => createEaseInOut,
|
|
23
|
+
createEaseOut: () => createEaseOut
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createEases_exports);
|
|
26
|
+
function createEaseOut(easeIn) {
|
|
27
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
28
|
+
}
|
|
29
|
+
function createEaseInOut(easeIn) {
|
|
30
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
31
|
+
}
|
|
32
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {(progress: number) => number} EasingFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create an out easing function.
|
|
6
|
+
*
|
|
7
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
+
* @returns {EasingFunction} The out function.
|
|
9
|
+
*/
|
|
10
|
+
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
+
/**
|
|
12
|
+
* Create an in-out easing function.
|
|
13
|
+
*
|
|
14
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
+
* @returns {EasingFunction} The in-out function.
|
|
16
|
+
*/
|
|
17
|
+
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
+
export type EasingFunction = (progress: number) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function createEaseOut(easeIn) {
|
|
2
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
3
|
+
}
|
|
4
|
+
function createEaseInOut(easeIn) {
|
|
5
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
createEaseInOut,
|
|
9
|
+
createEaseOut
|
|
10
|
+
};
|
package/utils/math/ease.cjs
CHANGED
|
@@ -19,8 +19,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// packages/js-toolkit/utils/math/ease.js
|
|
20
20
|
var ease_exports = {};
|
|
21
21
|
__export(ease_exports, {
|
|
22
|
-
createEaseInOut: () => createEaseInOut,
|
|
23
|
-
createEaseOut: () => createEaseOut,
|
|
24
22
|
easeInCirc: () => easeInCirc,
|
|
25
23
|
easeInCubic: () => easeInCubic,
|
|
26
24
|
easeInExpo: () => easeInExpo,
|
|
@@ -44,45 +42,40 @@ __export(ease_exports, {
|
|
|
44
42
|
easeOutSine: () => easeOutSine
|
|
45
43
|
});
|
|
46
44
|
module.exports = __toCommonJS(ease_exports);
|
|
47
|
-
|
|
48
|
-
return (progress) => 1 - easeIn(1 - progress);
|
|
49
|
-
}
|
|
50
|
-
function createEaseInOut(easeIn) {
|
|
51
|
-
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
52
|
-
}
|
|
45
|
+
var import_createEases = require("./createEases.cjs");
|
|
53
46
|
function easeInQuad(progress) {
|
|
54
47
|
return progress ** 2;
|
|
55
48
|
}
|
|
56
|
-
var easeOutQuad = createEaseOut(easeInQuad);
|
|
57
|
-
var easeInOutQuad = createEaseInOut(easeInQuad);
|
|
49
|
+
var easeOutQuad = (0, import_createEases.createEaseOut)(easeInQuad);
|
|
50
|
+
var easeInOutQuad = (0, import_createEases.createEaseInOut)(easeInQuad);
|
|
58
51
|
function easeInCubic(progress) {
|
|
59
52
|
return progress ** 3;
|
|
60
53
|
}
|
|
61
|
-
var easeOutCubic = createEaseOut(easeInCubic);
|
|
62
|
-
var easeInOutCubic = createEaseInOut(easeInCubic);
|
|
54
|
+
var easeOutCubic = (0, import_createEases.createEaseOut)(easeInCubic);
|
|
55
|
+
var easeInOutCubic = (0, import_createEases.createEaseInOut)(easeInCubic);
|
|
63
56
|
function easeInQuart(progress) {
|
|
64
57
|
return progress ** 4;
|
|
65
58
|
}
|
|
66
|
-
var easeOutQuart = createEaseOut(easeInQuart);
|
|
67
|
-
var easeInOutQuart = createEaseInOut(easeInQuart);
|
|
59
|
+
var easeOutQuart = (0, import_createEases.createEaseOut)(easeInQuart);
|
|
60
|
+
var easeInOutQuart = (0, import_createEases.createEaseInOut)(easeInQuart);
|
|
68
61
|
function easeInQuint(progress) {
|
|
69
62
|
return progress ** 5;
|
|
70
63
|
}
|
|
71
|
-
var easeOutQuint = createEaseOut(easeInQuint);
|
|
72
|
-
var easeInOutQuint = createEaseInOut(easeInQuint);
|
|
64
|
+
var easeOutQuint = (0, import_createEases.createEaseOut)(easeInQuint);
|
|
65
|
+
var easeInOutQuint = (0, import_createEases.createEaseInOut)(easeInQuint);
|
|
73
66
|
function easeInSine(progress) {
|
|
74
67
|
return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
|
|
75
68
|
}
|
|
76
|
-
var easeOutSine = createEaseOut(easeInSine);
|
|
77
|
-
var easeInOutSine = createEaseInOut(easeInSine);
|
|
69
|
+
var easeOutSine = (0, import_createEases.createEaseOut)(easeInSine);
|
|
70
|
+
var easeInOutSine = (0, import_createEases.createEaseInOut)(easeInSine);
|
|
78
71
|
function easeInCirc(progress) {
|
|
79
72
|
return -(Math.sqrt(1 - progress * progress) - 1);
|
|
80
73
|
}
|
|
81
|
-
var easeOutCirc = createEaseOut(easeInCirc);
|
|
82
|
-
var easeInOutCirc = createEaseInOut(easeInCirc);
|
|
74
|
+
var easeOutCirc = (0, import_createEases.createEaseOut)(easeInCirc);
|
|
75
|
+
var easeInOutCirc = (0, import_createEases.createEaseInOut)(easeInCirc);
|
|
83
76
|
function easeInExpo(progress) {
|
|
84
77
|
return 2 ** (10 * (progress - 1));
|
|
85
78
|
}
|
|
86
|
-
var easeOutExpo = createEaseOut(easeInExpo);
|
|
87
|
-
var easeInOutExpo = createEaseInOut(easeInExpo);
|
|
79
|
+
var easeOutExpo = (0, import_createEases.createEaseOut)(easeInExpo);
|
|
80
|
+
var easeInOutExpo = (0, import_createEases.createEaseInOut)(easeInExpo);
|
|
88
81
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/ease.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Create an out easing function.
|
|
6
|
-
*
|
|
7
|
-
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
-
* @returns {EasingFunction} The out function.
|
|
9
|
-
*/
|
|
10
|
-
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
-
/**
|
|
12
|
-
* Create an in-out easing function.
|
|
13
|
-
*
|
|
14
|
-
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
-
* @returns {EasingFunction} The in-out function.
|
|
16
|
-
*/
|
|
17
|
-
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
-
/**
|
|
19
|
-
* @type {EasingFunction}
|
|
2
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
3
|
+
* @returns {number} Eased value between 0 and 1.
|
|
20
4
|
*/
|
|
21
5
|
export function easeInQuad(progress: number): number;
|
|
22
6
|
/**
|
|
@@ -61,18 +45,17 @@ export function easeInCirc(progress: number): number;
|
|
|
61
45
|
* @returns {number} Eased value between 0 and 1.
|
|
62
46
|
*/
|
|
63
47
|
export function easeInExpo(progress: number): number;
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export type EasingFunction = (progress: number) => number;
|
|
48
|
+
export const easeOutQuad: import("./createEases.js").EasingFunction;
|
|
49
|
+
export const easeInOutQuad: import("./createEases.js").EasingFunction;
|
|
50
|
+
export const easeOutCubic: import("./createEases.js").EasingFunction;
|
|
51
|
+
export const easeInOutCubic: import("./createEases.js").EasingFunction;
|
|
52
|
+
export const easeOutQuart: import("./createEases.js").EasingFunction;
|
|
53
|
+
export const easeInOutQuart: import("./createEases.js").EasingFunction;
|
|
54
|
+
export const easeOutQuint: import("./createEases.js").EasingFunction;
|
|
55
|
+
export const easeInOutQuint: import("./createEases.js").EasingFunction;
|
|
56
|
+
export const easeOutSine: import("./createEases.js").EasingFunction;
|
|
57
|
+
export const easeInOutSine: import("./createEases.js").EasingFunction;
|
|
58
|
+
export const easeOutCirc: import("./createEases.js").EasingFunction;
|
|
59
|
+
export const easeInOutCirc: import("./createEases.js").EasingFunction;
|
|
60
|
+
export const easeOutExpo: import("./createEases.js").EasingFunction;
|
|
61
|
+
export const easeInOutExpo: import("./createEases.js").EasingFunction;
|
package/utils/math/ease.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return (progress) => 1 - easeIn(1 - progress);
|
|
3
|
-
}
|
|
4
|
-
function createEaseInOut(easeIn) {
|
|
5
|
-
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
6
|
-
}
|
|
1
|
+
import { createEaseOut, createEaseInOut } from "./createEases.js";
|
|
7
2
|
function easeInQuad(progress) {
|
|
8
3
|
return progress ** 2;
|
|
9
4
|
}
|
|
@@ -40,8 +35,6 @@ function easeInExpo(progress) {
|
|
|
40
35
|
const easeOutExpo = createEaseOut(easeInExpo);
|
|
41
36
|
const easeInOutExpo = createEaseInOut(easeInExpo);
|
|
42
37
|
export {
|
|
43
|
-
createEaseInOut,
|
|
44
|
-
createEaseOut,
|
|
45
38
|
easeInCirc,
|
|
46
39
|
easeInCubic,
|
|
47
40
|
easeInExpo,
|
package/utils/math/index.cjs
CHANGED
|
@@ -42,4 +42,5 @@ var import_map = __toESM(require("./map.cjs"), 1);
|
|
|
42
42
|
var import_round = __toESM(require("./round.cjs"), 1);
|
|
43
43
|
__reExport(math_exports, require("./ease.cjs"), module.exports);
|
|
44
44
|
var ease = __toESM(require("./ease.cjs"), 1);
|
|
45
|
+
__reExport(math_exports, require("./createEases.cjs"), module.exports);
|
|
45
46
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/index.d.ts
CHANGED
package/utils/math/index.js
CHANGED