@douyinfe/semi-animation 2.1.0-next.0 → 2.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/package.json +3 -3
- package/lib/cjs/index.d.ts +0 -6
- package/lib/cjs/index.js +0 -69
- package/lib/cjs/src/Animation.d.ts +0 -55
- package/lib/cjs/src/Animation.js +0 -323
- package/lib/cjs/src/constants.d.ts +0 -1
- package/lib/cjs/src/constants.js +0 -11
- package/lib/cjs/src/getEasing.d.ts +0 -10
- package/lib/cjs/src/getEasing.js +0 -165
- package/lib/cjs/src/interpolate.d.ts +0 -13
- package/lib/cjs/src/interpolate.js +0 -62
- package/lib/cjs/src/mapToZero.d.ts +0 -1
- package/lib/cjs/src/mapToZero.js +0 -25
- package/lib/cjs/src/presets.d.ts +0 -18
- package/lib/cjs/src/presets.js +0 -41
- package/lib/cjs/src/shouldStopAnimation.d.ts +0 -13
- package/lib/cjs/src/shouldStopAnimation.js +0 -55
- package/lib/cjs/src/shouldUseBezier.d.ts +0 -1
- package/lib/cjs/src/shouldUseBezier.js +0 -13
- package/lib/cjs/src/stepper.d.ts +0 -16
- package/lib/cjs/src/stepper.js +0 -56
- package/lib/cjs/src/stripStyle.d.ts +0 -1
- package/lib/cjs/src/stripStyle.js +0 -24
- package/lib/cjs/src/utils/Event.d.ts +0 -7
- package/lib/cjs/src/utils/Event.js +0 -90
- package/lib/cjs/src/utils/debounce.d.ts +0 -6
- package/lib/cjs/src/utils/debounce.js +0 -33
- package/lib/cjs/src/utils/log.d.ts +0 -2
- package/lib/cjs/src/utils/log.js +0 -22
- package/lib/cjs/src/utils/noop.d.ts +0 -1
- package/lib/cjs/src/utils/noop.js +0 -12
- package/lib/cjs/src/utils/shallowEqual.d.ts +0 -1
- package/lib/cjs/src/utils/shallowEqual.js +0 -36
- package/lib/cjs/src/wrapValue.d.ts +0 -18
- package/lib/cjs/src/wrapValue.js +0 -61
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = interpolate;
|
|
12
|
-
|
|
13
|
-
var _parseFloat2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-float"));
|
|
14
|
-
|
|
15
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
16
|
-
|
|
17
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {number|number[]|string|string[]} from
|
|
22
|
-
* @param {number|number[]|string|string[]} to
|
|
23
|
-
* @param {number} ratio
|
|
24
|
-
* @param {Function} [parser]
|
|
25
|
-
* @param {Function} [formatter]
|
|
26
|
-
* @returns {any}
|
|
27
|
-
*/
|
|
28
|
-
// eslint-disable-next-line max-len
|
|
29
|
-
function interpolate(from, to) {
|
|
30
|
-
let ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
31
|
-
let parser = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
32
|
-
let formatter = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
33
|
-
|
|
34
|
-
if (typeof parser === 'function') {
|
|
35
|
-
from = parser(from);
|
|
36
|
-
to = parser(to);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (typeof from === 'string' || typeof from === 'number') {
|
|
40
|
-
from = [(0, _parseFloat2.default)(from)];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof to === 'string' || typeof to === 'number') {
|
|
44
|
-
to = [(0, _parseFloat2.default)(to)];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const result = [];
|
|
48
|
-
|
|
49
|
-
if ((0, _isArray.default)(from) && (0, _isArray.default)(to)) {
|
|
50
|
-
(0, _forEach.default)(from).call(from, (fromVal, idx) => {
|
|
51
|
-
fromVal = (0, _parseFloat2.default)(fromVal);
|
|
52
|
-
const toVal = (0, _parseFloat2.default)(to[idx]);
|
|
53
|
-
result.push((toVal - fromVal) * ratio + fromVal);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (typeof formatter === 'function') {
|
|
58
|
-
return formatter(result);
|
|
59
|
-
} else {
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function mapToZero(obj: Record<string, any>): {};
|
package/lib/cjs/src/mapToZero.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = mapToZero;
|
|
12
|
-
|
|
13
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
|
-
// currently used to initiate the velocity style object to 0
|
|
16
|
-
function mapToZero(obj) {
|
|
17
|
-
const ret = {};
|
|
18
|
-
const objKeys = obj && (0, _keys.default)(obj) || [];
|
|
19
|
-
|
|
20
|
-
for (const key of objKeys) {
|
|
21
|
-
ret[key] = 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return ret;
|
|
25
|
-
}
|
package/lib/cjs/src/presets.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* stiffness is like tension
|
|
3
|
-
* damping is like friction
|
|
4
|
-
*/
|
|
5
|
-
export interface PresetsItem {
|
|
6
|
-
tension: number;
|
|
7
|
-
friction: number;
|
|
8
|
-
}
|
|
9
|
-
export interface Presets {
|
|
10
|
-
default: PresetsItem;
|
|
11
|
-
gentle: PresetsItem;
|
|
12
|
-
wobbly: PresetsItem;
|
|
13
|
-
stiff: PresetsItem;
|
|
14
|
-
slow: PresetsItem;
|
|
15
|
-
molasses: PresetsItem;
|
|
16
|
-
}
|
|
17
|
-
declare const _default: Presets;
|
|
18
|
-
export default _default;
|
package/lib/cjs/src/presets.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = void 0;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* stiffness is like tension
|
|
13
|
-
* damping is like friction
|
|
14
|
-
*/
|
|
15
|
-
var _default = {
|
|
16
|
-
default: {
|
|
17
|
-
tension: 170,
|
|
18
|
-
friction: 26
|
|
19
|
-
},
|
|
20
|
-
gentle: {
|
|
21
|
-
tension: 120,
|
|
22
|
-
friction: 14
|
|
23
|
-
},
|
|
24
|
-
wobbly: {
|
|
25
|
-
tension: 180,
|
|
26
|
-
friction: 12
|
|
27
|
-
},
|
|
28
|
-
stiff: {
|
|
29
|
-
tension: 210,
|
|
30
|
-
friction: 20
|
|
31
|
-
},
|
|
32
|
-
slow: {
|
|
33
|
-
tension: 280,
|
|
34
|
-
friction: 60
|
|
35
|
-
},
|
|
36
|
-
molasses: {
|
|
37
|
-
tension: 280,
|
|
38
|
-
friction: 120
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
exports.default = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* usage assumption: currentStyle values have already been rendered but it says
|
|
3
|
-
* nothing of whether currentStyle is stale (see unreadPropStyle)
|
|
4
|
-
*
|
|
5
|
-
* @param {object} currentStyle
|
|
6
|
-
* @param {object} style
|
|
7
|
-
* @param {object} currentVelocity
|
|
8
|
-
* @param {number} startTime
|
|
9
|
-
* @param {number} nowTime
|
|
10
|
-
*
|
|
11
|
-
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
export default function shouldStopAnimation(currentStyle: Record<string, any>, style: Record<string, any>, currentVelocity: Record<string, any>, startTime: number, nowTime: number): boolean;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = shouldStopAnimation;
|
|
12
|
-
|
|
13
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
|
-
var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* usage assumption: currentStyle values have already been rendered but it says
|
|
19
|
-
* nothing of whether currentStyle is stale (see unreadPropStyle)
|
|
20
|
-
*
|
|
21
|
-
* @param {object} currentStyle
|
|
22
|
-
* @param {object} style
|
|
23
|
-
* @param {object} currentVelocity
|
|
24
|
-
* @param {number} startTime
|
|
25
|
-
* @param {number} nowTime
|
|
26
|
-
*
|
|
27
|
-
* @returns {boolean}
|
|
28
|
-
*/
|
|
29
|
-
// eslint-disable-next-line max-len
|
|
30
|
-
function shouldStopAnimation(currentStyle, style, currentVelocity, startTime, nowTime) {
|
|
31
|
-
for (const key of (0, _keys.default)(style)) {
|
|
32
|
-
const styleValue = style[key];
|
|
33
|
-
const value = typeof styleValue === 'number' ? styleValue : styleValue.val;
|
|
34
|
-
|
|
35
|
-
if (typeof styleValue === 'object' && styleValue.done) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if ((0, _shouldUseBezier.default)(styleValue) && startTime && nowTime && styleValue.duration) {
|
|
40
|
-
if (styleValue.duration + startTime <= nowTime || value !== currentStyle[key]) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
} else if (typeof currentVelocity[key] === 'number' && currentVelocity[key] !== 0) {
|
|
44
|
-
return false;
|
|
45
|
-
} // stepper will have already taken care of rounding precision errors, so
|
|
46
|
-
// won't have such thing as 0.9999 !=== 1
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (currentStyle[key] !== value) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function shouldUseBezier(config: Record<string, any>): boolean;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = shouldUseBezier;
|
|
10
|
-
|
|
11
|
-
function shouldUseBezier(config) {
|
|
12
|
-
return Boolean(config && typeof config === 'object' && (config.duration > 0 || typeof config.easing === 'string' || typeof config.easing === 'function'));
|
|
13
|
-
}
|
package/lib/cjs/src/stepper.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
4
|
-
* react-motion/src/stepper.js
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {number} secondPerFrame
|
|
9
|
-
* @param {number} x
|
|
10
|
-
* @param {number} v
|
|
11
|
-
* @param {number} destX
|
|
12
|
-
* @param {number} k
|
|
13
|
-
* @param {number} b
|
|
14
|
-
* @param {number} precision
|
|
15
|
-
*/
|
|
16
|
-
export default function stepper(secondPerFrame: number, x: number, v: number, destX: number, k: number, b: number, precision: number): number[];
|
package/lib/cjs/src/stepper.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = stepper;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @file
|
|
13
|
-
*
|
|
14
|
-
* react-motion/src/stepper.js
|
|
15
|
-
*/
|
|
16
|
-
// stepper is used a lot. Saves allocation to return the same array wrapper.
|
|
17
|
-
// This is fine and danger-free against mutations because the callsite
|
|
18
|
-
// immediately destructures it and gets the numbers inside without passing the
|
|
19
|
-
// array reference around.
|
|
20
|
-
const reusedTuple = [0, 0];
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {number} secondPerFrame
|
|
24
|
-
* @param {number} x
|
|
25
|
-
* @param {number} v
|
|
26
|
-
* @param {number} destX
|
|
27
|
-
* @param {number} k
|
|
28
|
-
* @param {number} b
|
|
29
|
-
* @param {number} precision
|
|
30
|
-
*/
|
|
31
|
-
// eslint-disable-next-line max-len
|
|
32
|
-
|
|
33
|
-
function stepper(secondPerFrame, x, v, destX, k, b, precision) {
|
|
34
|
-
// Spring stiffness, in kg / s^2
|
|
35
|
-
// for animations, destX is really spring length (spring at rest). initial
|
|
36
|
-
// position is considered as the stretched/compressed position of a spring
|
|
37
|
-
const Fspring = -k * (x - destX); // Damping, in kg / s
|
|
38
|
-
|
|
39
|
-
const Fdamper = -b * v; // usually we put mass here, but for animation purposes, specifying mass is a
|
|
40
|
-
// bit redundant. you could simply adjust k and b accordingly
|
|
41
|
-
// let a = (Fspring + Fdamper) / mass;
|
|
42
|
-
|
|
43
|
-
const a = Fspring + Fdamper;
|
|
44
|
-
const newV = v + a * secondPerFrame;
|
|
45
|
-
const newX = x + newV * secondPerFrame;
|
|
46
|
-
|
|
47
|
-
if (Math.abs(newV) < precision && Math.abs(newX - destX) < precision) {
|
|
48
|
-
reusedTuple[0] = destX;
|
|
49
|
-
reusedTuple[1] = 0;
|
|
50
|
-
return reusedTuple;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
reusedTuple[0] = newX;
|
|
54
|
-
reusedTuple[1] = newV;
|
|
55
|
-
return reusedTuple;
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function stripStyle(style: Record<string, any>): {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = stripStyle;
|
|
10
|
-
|
|
11
|
-
/* eslint-disable no-restricted-syntax */
|
|
12
|
-
function stripStyle(style) {
|
|
13
|
-
const ret = {};
|
|
14
|
-
|
|
15
|
-
for (const key in style) {
|
|
16
|
-
if (!Object.prototype.hasOwnProperty.call(style, key)) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ret[key] = typeof style[key] === 'number' ? style[key] : style[key].val;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return ret;
|
|
24
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = void 0;
|
|
12
|
-
|
|
13
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
14
|
-
|
|
15
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
16
|
-
|
|
17
|
-
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
18
|
-
|
|
19
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
20
|
-
|
|
21
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
22
|
-
|
|
23
|
-
class Event {
|
|
24
|
-
constructor() {
|
|
25
|
-
this._eventMap = new _map.default();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
on(event, callback) {
|
|
29
|
-
if (event && typeof callback === 'function') {
|
|
30
|
-
this._eventMap.has(event) || this._eventMap.set(event, []);
|
|
31
|
-
|
|
32
|
-
this._eventMap.get(event).push(callback);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
once(event, callback) {
|
|
39
|
-
var _this = this;
|
|
40
|
-
|
|
41
|
-
if (event && typeof callback === 'function') {
|
|
42
|
-
const fn = function () {
|
|
43
|
-
callback(...arguments);
|
|
44
|
-
|
|
45
|
-
_this.off(event, fn);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
this.on(event, fn);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
off(event, callback) {
|
|
53
|
-
if (event) {
|
|
54
|
-
if (typeof callback === 'function') {
|
|
55
|
-
const callbacks = this._eventMap.get(event);
|
|
56
|
-
|
|
57
|
-
if ((0, _isArray.default)(callbacks) && callbacks.length) {
|
|
58
|
-
let index = -1; // eslint-disable-next-line max-depth
|
|
59
|
-
|
|
60
|
-
while ((index = (0, _findIndex.default)(callbacks).call(callbacks, cb => cb === callback)) > -1) {
|
|
61
|
-
(0, _splice.default)(callbacks).call(callbacks, index, 1);
|
|
62
|
-
}
|
|
63
|
-
} // eslint-disable-next-line eqeqeq
|
|
64
|
-
|
|
65
|
-
} else if (callback == null) {
|
|
66
|
-
this._eventMap.delete(event);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
emit(event) {
|
|
74
|
-
var _context;
|
|
75
|
-
|
|
76
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
77
|
-
args[_key - 1] = arguments[_key];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!this._eventMap.has(event)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
(0, _forEach.default)(_context = this._eventMap.get(event)).call(_context, callback => callback(...args));
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
exports.default = Event;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = debounce;
|
|
12
|
-
|
|
13
|
-
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {Function} func
|
|
18
|
-
* @param {number} delay
|
|
19
|
-
*/
|
|
20
|
-
function debounce(func) {
|
|
21
|
-
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
22
|
-
let timeoutId;
|
|
23
|
-
return function () {
|
|
24
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
-
args[_key] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
29
|
-
const context = this;
|
|
30
|
-
clearTimeout(timeoutId);
|
|
31
|
-
timeoutId = (0, _setTimeout2.default)(() => func.apply(context, args), delay);
|
|
32
|
-
};
|
|
33
|
-
}
|
package/lib/cjs/src/utils/log.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = void 0;
|
|
10
|
-
|
|
11
|
-
const log = function (text) {
|
|
12
|
-
if (process.env.NODE_ENV === 'development') {
|
|
13
|
-
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
14
|
-
rest[_key - 1] = arguments[_key];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.log(text, ...rest);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
var _default = log;
|
|
22
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function noop(): void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = noop;
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
|
-
function noop() {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function shallowEqual(a: any, b: any): boolean;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
exports.default = shallowEqual;
|
|
10
|
-
|
|
11
|
-
/* eslint-disable no-restricted-syntax */
|
|
12
|
-
function shallowEqual(a, b) {
|
|
13
|
-
if (typeof a !== typeof b) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof a === 'string' || typeof a === 'number') {
|
|
18
|
-
return a === b;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let i;
|
|
22
|
-
|
|
23
|
-
for (i in a) {
|
|
24
|
-
if (!(i in b)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
for (i in b) {
|
|
30
|
-
if (a[i] !== b[i]) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return i === void 0 ? a === b : true;
|
|
36
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PresetsItem } from './presets';
|
|
2
|
-
export interface Value {
|
|
3
|
-
easing: string;
|
|
4
|
-
duration: number | string;
|
|
5
|
-
}
|
|
6
|
-
export interface DefaultConfig extends PresetsItem {
|
|
7
|
-
precision: number;
|
|
8
|
-
}
|
|
9
|
-
export interface Config {
|
|
10
|
-
easing?: string;
|
|
11
|
-
duration?: number | string;
|
|
12
|
-
delay?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface Wrapped extends DefaultConfig, Config {
|
|
15
|
-
done: boolean;
|
|
16
|
-
val?: Value;
|
|
17
|
-
}
|
|
18
|
-
export default function wrapValue(val: Value, config?: Config): Wrapped;
|
package/lib/cjs/src/wrapValue.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = wrapValue;
|
|
12
|
-
|
|
13
|
-
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
14
|
-
|
|
15
|
-
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
|
|
16
|
-
|
|
17
|
-
var _getEasing = _interopRequireDefault(require("./getEasing"));
|
|
18
|
-
|
|
19
|
-
var _presets = _interopRequireDefault(require("./presets"));
|
|
20
|
-
|
|
21
|
-
var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
|
|
22
|
-
|
|
23
|
-
const defaultConfig = (0, _assign.default)((0, _assign.default)({}, _presets.default.default), {
|
|
24
|
-
precision: 0.01
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
function wrapValue(val) {
|
|
28
|
-
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29
|
-
|
|
30
|
-
if ((0, _shouldUseBezier.default)(config)) {
|
|
31
|
-
const easing = (0, _getEasing.default)(config.easing);
|
|
32
|
-
const duration = typeof config.duration === 'number' && config.duration > 0 ? config.duration : 1000;
|
|
33
|
-
config = (0, _assign.default)((0, _assign.default)({}, config), {
|
|
34
|
-
easing,
|
|
35
|
-
duration
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let wrapped = (0, _assign.default)((0, _assign.default)((0, _assign.default)({}, defaultConfig), config), {
|
|
40
|
-
done: false
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (val && typeof val === 'object' && 'val' in val) {
|
|
44
|
-
if ((0, _shouldUseBezier.default)(val)) {
|
|
45
|
-
const easing = (0, _getEasing.default)(val.easing);
|
|
46
|
-
const duration = typeof val.duration === 'number' && val.duration > 0 ? val.duration : (0, _parseInt2.default)(config.duration) || 1000;
|
|
47
|
-
val = (0, _assign.default)((0, _assign.default)({}, val), {
|
|
48
|
-
easing,
|
|
49
|
-
duration
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
wrapped = (0, _assign.default)((0, _assign.default)({}, wrapped), val);
|
|
54
|
-
} else {
|
|
55
|
-
wrapped = (0, _assign.default)((0, _assign.default)({}, wrapped), {
|
|
56
|
-
val
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return wrapped;
|
|
61
|
-
}
|