@studiometa/js-toolkit 2.2.3 → 2.3.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/Base/index.cjs +60 -68
- package/Base/index.d.ts +0 -8
- package/Base/index.js +67 -81
- package/Base/managers/AbstractManager.cjs +5 -10
- package/Base/managers/AbstractManager.js +5 -11
- package/Base/managers/ChildrenManager.cjs +2 -11
- package/Base/managers/ChildrenManager.js +2 -12
- package/Base/managers/EventsManager.cjs +61 -67
- package/Base/managers/EventsManager.js +61 -68
- package/Base/managers/OptionsManager.cjs +26 -27
- package/Base/managers/OptionsManager.js +26 -28
- package/Base/managers/RefsManager.cjs +9 -7
- package/Base/managers/RefsManager.js +9 -7
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ResponsiveOptionsManager.js +4 -1
- package/Base/managers/ServicesManager.cjs +6 -11
- package/Base/managers/ServicesManager.js +7 -13
- package/Base/utils.cjs +23 -1
- package/Base/utils.d.ts +25 -0
- package/Base/utils.js +23 -1
- package/decorators/withBreakpointManager.cjs +15 -5
- package/decorators/withBreakpointManager.js +15 -5
- package/decorators/withBreakpointObserver.cjs +19 -18
- package/decorators/withBreakpointObserver.js +19 -19
- package/decorators/withDrag.cjs +6 -11
- package/decorators/withDrag.js +6 -12
- package/decorators/withExtraConfig.cjs +3 -8
- package/decorators/withExtraConfig.js +3 -9
- package/decorators/withFreezedOptions.cjs +1 -9
- package/decorators/withFreezedOptions.js +1 -10
- package/decorators/withIntersectionObserver.cjs +11 -16
- package/decorators/withIntersectionObserver.js +11 -17
- package/decorators/withMountWhenInView.cjs +12 -17
- package/decorators/withMountWhenInView.js +12 -18
- package/decorators/withScrolledInView.cjs +30 -35
- package/decorators/withScrolledInView.js +30 -36
- package/decorators/withVue2.cjs +20 -18
- package/decorators/withVue2.js +20 -19
- package/helpers/getInstanceFromElement.cjs +1 -2
- package/helpers/getInstanceFromElement.js +1 -2
- package/helpers/importOnInteraction.cjs +3 -2
- package/helpers/importOnInteraction.js +3 -2
- package/helpers/importWhenIdle.cjs +2 -3
- package/helpers/importWhenIdle.js +2 -3
- package/helpers/importWhenVisible.cjs +3 -2
- package/helpers/importWhenVisible.js +3 -2
- package/helpers/utils.cjs +3 -2
- package/helpers/utils.js +3 -2
- package/package.json +4 -1
- package/services/key.cjs +1 -1
- package/services/key.js +1 -1
- package/services/pointer.cjs +2 -3
- package/services/pointer.js +2 -3
- package/services/raf.cjs +2 -5
- package/services/raf.js +1 -1
- package/utils/css/animate.cjs +33 -98
- package/utils/css/animate.d.ts +4 -16
- package/utils/css/animate.js +31 -96
- package/utils/css/classes.cjs +2 -1
- package/utils/css/classes.js +2 -1
- package/utils/css/matrix.cjs +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.cjs +2 -5
- package/utils/css/styles.js +1 -1
- package/utils/css/transform.cjs +14 -18
- package/utils/css/transform.js +2 -3
- package/utils/css/transition.cjs +7 -10
- package/utils/css/transition.js +7 -11
- package/utils/focusTrap.cjs +2 -1
- package/utils/focusTrap.js +2 -1
- package/utils/{isFunction.cjs → has.cjs} +7 -7
- package/utils/has.d.ts +6 -0
- package/utils/has.js +6 -0
- package/utils/history.cjs +5 -7
- package/utils/history.js +4 -3
- package/utils/index.cjs +5 -5
- package/utils/index.d.ts +3 -2
- package/utils/index.js +5 -5
- package/utils/{isDefined.cjs → is.cjs} +20 -8
- package/utils/is.d.ts +8 -0
- package/utils/is.js +18 -0
- package/utils/math/inertiaFinalValue.cjs +5 -3
- package/utils/math/inertiaFinalValue.js +2 -3
- package/utils/nextFrame.cjs +5 -3
- package/utils/nextFrame.js +5 -3
- package/utils/nextMicrotask.cjs +2 -1
- package/utils/nextMicrotask.js +2 -1
- package/utils/nextTick.cjs +2 -1
- package/utils/nextTick.js +2 -1
- package/utils/object/autoBind.cjs +3 -2
- package/utils/object/autoBind.js +3 -2
- package/utils/object/getAllProperties.cjs +2 -1
- package/utils/object/getAllProperties.js +2 -1
- package/utils/object/index.cjs +1 -3
- package/utils/object/index.d.ts +0 -1
- package/utils/object/index.js +1 -3
- package/utils/tween.cjs +113 -0
- package/utils/tween.d.ts +25 -0
- package/utils/tween.js +88 -0
- package/utils/isDefined.d.ts +0 -7
- package/utils/isDefined.js +0 -6
- package/utils/isFunction.d.ts +0 -7
- package/utils/isFunction.js +0 -6
- package/utils/object/isObject.cjs +0 -28
- package/utils/object/isObject.d.ts +0 -7
- package/utils/object/isObject.js +0 -6
package/utils/nextFrame.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { isFunction } from "./is.js";
|
|
2
|
+
import { hasWindow } from "./has.js";
|
|
1
3
|
function getRaf() {
|
|
2
|
-
return
|
|
4
|
+
return hasWindow() && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
|
|
3
5
|
}
|
|
4
6
|
function getCancelRaf() {
|
|
5
|
-
return
|
|
7
|
+
return hasWindow() && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
|
|
6
8
|
}
|
|
7
9
|
function nextFrame(fn) {
|
|
8
10
|
return new Promise((resolve) => {
|
|
9
|
-
getRaf()(() => resolve(
|
|
11
|
+
getRaf()(() => resolve(isFunction(fn) && fn()));
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
export {
|
package/utils/nextMicrotask.cjs
CHANGED
|
@@ -22,7 +22,8 @@ __export(nextMicrotask_exports, {
|
|
|
22
22
|
default: () => nextMicrotask
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(nextMicrotask_exports);
|
|
25
|
+
var import_is = require("./is.cjs");
|
|
25
26
|
async function nextMicrotask(fn) {
|
|
26
|
-
return Promise.resolve().then(() =>
|
|
27
|
+
return Promise.resolve().then(() => (0, import_is.isFunction)(fn) && fn());
|
|
27
28
|
}
|
|
28
29
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/nextMicrotask.js
CHANGED
package/utils/nextTick.cjs
CHANGED
|
@@ -22,9 +22,10 @@ __export(nextTick_exports, {
|
|
|
22
22
|
default: () => nextTick
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(nextTick_exports);
|
|
25
|
+
var import_is = require("./is.cjs");
|
|
25
26
|
async function nextTick(fn) {
|
|
26
27
|
return new Promise((resolve) => setTimeout(() => {
|
|
27
|
-
resolve(
|
|
28
|
+
resolve((0, import_is.isFunction)(fn) && fn());
|
|
28
29
|
}, 0));
|
|
29
30
|
}
|
|
30
31
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/nextTick.js
CHANGED
|
@@ -26,10 +26,11 @@ __export(autoBind_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(autoBind_exports);
|
|
28
28
|
var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
|
|
29
|
+
var import_is = require("../is.cjs");
|
|
29
30
|
function autoBind(instance, options) {
|
|
30
31
|
const { exclude, include } = options || {};
|
|
31
32
|
const filter = (key) => {
|
|
32
|
-
const match = (pattern) =>
|
|
33
|
+
const match = (pattern) => (0, import_is.isString)(pattern) ? key === pattern : pattern.test(key);
|
|
33
34
|
if (include) {
|
|
34
35
|
return include.some(match);
|
|
35
36
|
}
|
|
@@ -40,7 +41,7 @@ function autoBind(instance, options) {
|
|
|
40
41
|
};
|
|
41
42
|
(0, import_getAllProperties.default)(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
|
|
42
43
|
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
43
|
-
if (descriptor &&
|
|
44
|
+
if (descriptor && (0, import_is.isFunction)(descriptor.value)) {
|
|
44
45
|
instance[key] = instance[key].bind(instance);
|
|
45
46
|
}
|
|
46
47
|
});
|
package/utils/object/autoBind.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import getAllProperties from "./getAllProperties.js";
|
|
2
|
+
import { isString, isFunction } from "../is.js";
|
|
2
3
|
function autoBind(instance, options) {
|
|
3
4
|
const { exclude, include } = options || {};
|
|
4
5
|
const filter = (key) => {
|
|
5
|
-
const match = (pattern) =>
|
|
6
|
+
const match = (pattern) => isString(pattern) ? key === pattern : pattern.test(key);
|
|
6
7
|
if (include) {
|
|
7
8
|
return include.some(match);
|
|
8
9
|
}
|
|
@@ -13,7 +14,7 @@ function autoBind(instance, options) {
|
|
|
13
14
|
};
|
|
14
15
|
getAllProperties(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
|
|
15
16
|
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
16
|
-
if (descriptor &&
|
|
17
|
+
if (descriptor && isFunction(descriptor.value)) {
|
|
17
18
|
instance[key] = instance[key].bind(instance);
|
|
18
19
|
}
|
|
19
20
|
});
|
|
@@ -22,13 +22,14 @@ __export(getAllProperties_exports, {
|
|
|
22
22
|
default: () => getAllProperties
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(getAllProperties_exports);
|
|
25
|
+
var import_is = require("../is.cjs");
|
|
25
26
|
function getAllProperties(object, props = [], testFn = null) {
|
|
26
27
|
const proto = Object.getPrototypeOf(object);
|
|
27
28
|
if (proto === Object.prototype || proto === null) {
|
|
28
29
|
return props;
|
|
29
30
|
}
|
|
30
31
|
let foundProps = Object.getOwnPropertyNames(proto);
|
|
31
|
-
if (
|
|
32
|
+
if ((0, import_is.isFunction)(testFn)) {
|
|
32
33
|
foundProps = foundProps.filter((name) => testFn(name, proto));
|
|
33
34
|
}
|
|
34
35
|
foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { isFunction } from "../is.js";
|
|
1
2
|
function getAllProperties(object, props = [], testFn = null) {
|
|
2
3
|
const proto = Object.getPrototypeOf(object);
|
|
3
4
|
if (proto === Object.prototype || proto === null) {
|
|
4
5
|
return props;
|
|
5
6
|
}
|
|
6
7
|
let foundProps = Object.getOwnPropertyNames(proto);
|
|
7
|
-
if (
|
|
8
|
+
if (isFunction(testFn)) {
|
|
8
9
|
foundProps = foundProps.filter((name) => testFn(name, proto));
|
|
9
10
|
}
|
|
10
11
|
foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
|
package/utils/object/index.cjs
CHANGED
|
@@ -23,11 +23,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
var object_exports = {};
|
|
24
24
|
__export(object_exports, {
|
|
25
25
|
autoBind: () => import_autoBind.default,
|
|
26
|
-
getAllProperties: () => import_getAllProperties.default
|
|
27
|
-
isObject: () => import_isObject.default
|
|
26
|
+
getAllProperties: () => import_getAllProperties.default
|
|
28
27
|
});
|
|
29
28
|
module.exports = __toCommonJS(object_exports);
|
|
30
29
|
var import_autoBind = __toESM(require("./autoBind.cjs"), 1);
|
|
31
30
|
var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
|
|
32
|
-
var import_isObject = __toESM(require("./isObject.cjs"), 1);
|
|
33
31
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/object/index.d.ts
CHANGED
package/utils/object/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { default as default2 } from "./autoBind.js";
|
|
2
2
|
import { default as default3 } from "./getAllProperties.js";
|
|
3
|
-
import { default as default4 } from "./isObject.js";
|
|
4
3
|
export {
|
|
5
4
|
default2 as autoBind,
|
|
6
|
-
default3 as getAllProperties
|
|
7
|
-
default4 as isObject
|
|
5
|
+
default3 as getAllProperties
|
|
8
6
|
};
|
package/utils/tween.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/js-toolkit/utils/tween.js
|
|
23
|
+
var tween_exports = {};
|
|
24
|
+
__export(tween_exports, {
|
|
25
|
+
normalizeEase: () => normalizeEase,
|
|
26
|
+
tween: () => tween
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(tween_exports);
|
|
29
|
+
var import_easing = require("@motionone/easing");
|
|
30
|
+
var import_math = require("./math/index.cjs");
|
|
31
|
+
var import_is = require("./is.cjs");
|
|
32
|
+
var import_noop = require("./noop.cjs");
|
|
33
|
+
var import_raf = __toESM(require("../services/raf.cjs"), 1);
|
|
34
|
+
var id = 0;
|
|
35
|
+
var PROGRESS_PRECISION = 1e-4;
|
|
36
|
+
function normalizeEase(ease) {
|
|
37
|
+
if (!(0, import_is.isDefined)(ease)) {
|
|
38
|
+
return import_noop.noopValue;
|
|
39
|
+
}
|
|
40
|
+
if ((0, import_is.isArray)(ease)) {
|
|
41
|
+
return (0, import_easing.cubicBezier)(...ease);
|
|
42
|
+
}
|
|
43
|
+
return ease;
|
|
44
|
+
}
|
|
45
|
+
function tween(callback, options = {}) {
|
|
46
|
+
const raf = (0, import_raf.default)();
|
|
47
|
+
let progressValue = 0;
|
|
48
|
+
let easedProgress = 0;
|
|
49
|
+
const ease = normalizeEase(options.easing);
|
|
50
|
+
let duration = options.duration ?? 1;
|
|
51
|
+
duration *= 1e3;
|
|
52
|
+
let startTime = performance.now();
|
|
53
|
+
let endTime = startTime + duration;
|
|
54
|
+
const key = `tw-${id}`;
|
|
55
|
+
id += 1;
|
|
56
|
+
const { onStart = import_noop.noop, onProgress = import_noop.noop, onFinish = import_noop.noop } = options;
|
|
57
|
+
let isRunning = false;
|
|
58
|
+
function pause() {
|
|
59
|
+
isRunning = false;
|
|
60
|
+
raf.remove(key);
|
|
61
|
+
}
|
|
62
|
+
function progress(newProgress) {
|
|
63
|
+
if (typeof newProgress === "undefined") {
|
|
64
|
+
return easedProgress;
|
|
65
|
+
}
|
|
66
|
+
progressValue = newProgress;
|
|
67
|
+
easedProgress = ease(progressValue);
|
|
68
|
+
if (Math.abs(1 - easedProgress) < PROGRESS_PRECISION) {
|
|
69
|
+
progressValue = 1;
|
|
70
|
+
easedProgress = 1;
|
|
71
|
+
}
|
|
72
|
+
callback(easedProgress);
|
|
73
|
+
onProgress(progressValue, easedProgress);
|
|
74
|
+
if (easedProgress === 1) {
|
|
75
|
+
pause();
|
|
76
|
+
requestAnimationFrame(() => onFinish(progressValue, easedProgress));
|
|
77
|
+
}
|
|
78
|
+
return progressValue;
|
|
79
|
+
}
|
|
80
|
+
function tick(props) {
|
|
81
|
+
if (!isRunning) {
|
|
82
|
+
raf.remove(key);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
progress((0, import_math.clamp01)((0, import_math.map)(props.time, startTime, endTime, 0, 1)));
|
|
86
|
+
}
|
|
87
|
+
function start() {
|
|
88
|
+
onStart();
|
|
89
|
+
startTime = performance.now();
|
|
90
|
+
endTime = startTime + duration;
|
|
91
|
+
progressValue = 0;
|
|
92
|
+
easedProgress = 0;
|
|
93
|
+
isRunning = true;
|
|
94
|
+
raf.add(key, tick);
|
|
95
|
+
}
|
|
96
|
+
function play() {
|
|
97
|
+
if (isRunning) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
startTime = performance.now() - (0, import_math.lerp)(0, duration, progressValue);
|
|
101
|
+
endTime = startTime + duration;
|
|
102
|
+
isRunning = true;
|
|
103
|
+
raf.add(key, tick);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
start,
|
|
107
|
+
finish: () => progress(1),
|
|
108
|
+
pause,
|
|
109
|
+
play,
|
|
110
|
+
progress
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/tween.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {[number, number, number, number]} BezierCurve
|
|
3
|
+
* @typedef {{
|
|
4
|
+
* duration?: number;
|
|
5
|
+
* easing?: import('./math/createEases.js').EasingFunction|BezierCurve;
|
|
6
|
+
* onStart?: () => void;
|
|
7
|
+
* onProgress?: (progress: number, easedProgress: number) => void;
|
|
8
|
+
* onFinish?: (progress: number, easedProgress: number) => void;
|
|
9
|
+
* }} TweenOptions
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Normalize a easing function with default fallbacks.
|
|
13
|
+
* @param {((p:number) => number)|[number,number,number,number]} ease
|
|
14
|
+
* @returns {(p:number) => number}
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeEase(ease: [number, number, number, number] | ((p: number) => number)): (p: number) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Tween from 0 to 1.
|
|
19
|
+
* @param {(progress:number)=>any} callback
|
|
20
|
+
* @param {TweenOptions} [options]
|
|
21
|
+
* @returns {any}
|
|
22
|
+
*/
|
|
23
|
+
export function tween(callback: (progress: number) => any, options?: TweenOptions): any;
|
|
24
|
+
export type BezierCurve = [number, number, number, number];
|
|
25
|
+
export type TweenOptions = TweenOptions;
|
package/utils/tween.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cubicBezier } from "@motionone/easing";
|
|
2
|
+
import { lerp, map, clamp01 } from "./math/index.js";
|
|
3
|
+
import { isDefined, isArray } from "./is.js";
|
|
4
|
+
import { noop, noopValue as linear } from "./noop.js";
|
|
5
|
+
import useRaf from "../services/raf.js";
|
|
6
|
+
let id = 0;
|
|
7
|
+
const PROGRESS_PRECISION = 1e-4;
|
|
8
|
+
function normalizeEase(ease) {
|
|
9
|
+
if (!isDefined(ease)) {
|
|
10
|
+
return linear;
|
|
11
|
+
}
|
|
12
|
+
if (isArray(ease)) {
|
|
13
|
+
return cubicBezier(...ease);
|
|
14
|
+
}
|
|
15
|
+
return ease;
|
|
16
|
+
}
|
|
17
|
+
function tween(callback, options = {}) {
|
|
18
|
+
const raf = useRaf();
|
|
19
|
+
let progressValue = 0;
|
|
20
|
+
let easedProgress = 0;
|
|
21
|
+
const ease = normalizeEase(options.easing);
|
|
22
|
+
let duration = options.duration ?? 1;
|
|
23
|
+
duration *= 1e3;
|
|
24
|
+
let startTime = performance.now();
|
|
25
|
+
let endTime = startTime + duration;
|
|
26
|
+
const key = `tw-${id}`;
|
|
27
|
+
id += 1;
|
|
28
|
+
const { onStart = noop, onProgress = noop, onFinish = noop } = options;
|
|
29
|
+
let isRunning = false;
|
|
30
|
+
function pause() {
|
|
31
|
+
isRunning = false;
|
|
32
|
+
raf.remove(key);
|
|
33
|
+
}
|
|
34
|
+
function progress(newProgress) {
|
|
35
|
+
if (typeof newProgress === "undefined") {
|
|
36
|
+
return easedProgress;
|
|
37
|
+
}
|
|
38
|
+
progressValue = newProgress;
|
|
39
|
+
easedProgress = ease(progressValue);
|
|
40
|
+
if (Math.abs(1 - easedProgress) < PROGRESS_PRECISION) {
|
|
41
|
+
progressValue = 1;
|
|
42
|
+
easedProgress = 1;
|
|
43
|
+
}
|
|
44
|
+
callback(easedProgress);
|
|
45
|
+
onProgress(progressValue, easedProgress);
|
|
46
|
+
if (easedProgress === 1) {
|
|
47
|
+
pause();
|
|
48
|
+
requestAnimationFrame(() => onFinish(progressValue, easedProgress));
|
|
49
|
+
}
|
|
50
|
+
return progressValue;
|
|
51
|
+
}
|
|
52
|
+
function tick(props) {
|
|
53
|
+
if (!isRunning) {
|
|
54
|
+
raf.remove(key);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
progress(clamp01(map(props.time, startTime, endTime, 0, 1)));
|
|
58
|
+
}
|
|
59
|
+
function start() {
|
|
60
|
+
onStart();
|
|
61
|
+
startTime = performance.now();
|
|
62
|
+
endTime = startTime + duration;
|
|
63
|
+
progressValue = 0;
|
|
64
|
+
easedProgress = 0;
|
|
65
|
+
isRunning = true;
|
|
66
|
+
raf.add(key, tick);
|
|
67
|
+
}
|
|
68
|
+
function play() {
|
|
69
|
+
if (isRunning) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
startTime = performance.now() - lerp(0, duration, progressValue);
|
|
73
|
+
endTime = startTime + duration;
|
|
74
|
+
isRunning = true;
|
|
75
|
+
raf.add(key, tick);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
start,
|
|
79
|
+
finish: () => progress(1),
|
|
80
|
+
pause,
|
|
81
|
+
play,
|
|
82
|
+
progress
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
normalizeEase,
|
|
87
|
+
tween
|
|
88
|
+
};
|
package/utils/isDefined.d.ts
DELETED
package/utils/isDefined.js
DELETED
package/utils/isFunction.d.ts
DELETED
package/utils/isFunction.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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/object/isObject.js
|
|
20
|
-
var isObject_exports = {};
|
|
21
|
-
__export(isObject_exports, {
|
|
22
|
-
default: () => isObject
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(isObject_exports);
|
|
25
|
-
function isObject(value) {
|
|
26
|
-
return typeof value === "object" && !!value && value.toString() === "[object Object]";
|
|
27
|
-
}
|
|
28
|
-
if (module.exports.default) module.exports = module.exports.default;
|