@douyinfe/semi-animation 2.19.0-alpha.8 → 2.19.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/lib/cjs/index.js +11 -23
- package/lib/cjs/src/Animation.js +24 -37
- package/lib/cjs/src/constants.js +1 -4
- package/lib/cjs/src/getEasing.js +7 -24
- package/lib/cjs/src/interpolate.js +7 -18
- package/lib/cjs/src/mapToZero.js +2 -9
- package/lib/cjs/src/presets.js +1 -4
- package/lib/cjs/src/shouldStopAnimation.js +4 -9
- package/lib/cjs/src/shouldUseBezier.js +1 -4
- package/lib/cjs/src/stepper.js +1 -4
- package/lib/cjs/src/stripStyle.js +1 -4
- package/lib/cjs/src/utils/Event.js +7 -23
- package/lib/cjs/src/utils/debounce.js +2 -9
- package/lib/cjs/src/utils/log.js +1 -4
- package/lib/cjs/src/utils/noop.js +1 -4
- package/lib/cjs/src/utils/shallowEqual.js +1 -4
- package/lib/cjs/src/wrapValue.js +10 -17
- package/lib/es/src/Animation.js +21 -29
- package/lib/es/src/getEasing.js +4 -13
- package/lib/es/src/interpolate.js +6 -12
- package/lib/es/src/mapToZero.js +1 -2
- package/lib/es/src/shouldStopAnimation.js +1 -2
- package/lib/es/src/utils/Event.js +5 -12
- package/lib/es/src/utils/debounce.js +1 -3
- package/lib/es/src/wrapValue.js +7 -11
- package/package.json +2 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1,53 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
7
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
8
|
-
|
|
9
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
10
|
-
|
|
11
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
4
|
value: true
|
|
13
5
|
});
|
|
14
|
-
|
|
15
|
-
_Object$defineProperty(exports, "Animation", {
|
|
6
|
+
Object.defineProperty(exports, "Animation", {
|
|
16
7
|
enumerable: true,
|
|
17
8
|
get: function () {
|
|
18
9
|
return _Animation.default;
|
|
19
10
|
}
|
|
20
11
|
});
|
|
21
|
-
|
|
22
|
-
_Object$defineProperty(exports, "easingMap", {
|
|
12
|
+
Object.defineProperty(exports, "easingMap", {
|
|
23
13
|
enumerable: true,
|
|
24
14
|
get: function () {
|
|
25
15
|
return _getEasing.easingMap;
|
|
26
16
|
}
|
|
27
17
|
});
|
|
28
|
-
|
|
29
|
-
_Object$defineProperty(exports, "events", {
|
|
18
|
+
Object.defineProperty(exports, "events", {
|
|
30
19
|
enumerable: true,
|
|
31
20
|
get: function () {
|
|
32
21
|
return _constants.events;
|
|
33
22
|
}
|
|
34
23
|
});
|
|
35
|
-
|
|
36
|
-
_Object$defineProperty(exports, "getEasing", {
|
|
24
|
+
Object.defineProperty(exports, "getEasing", {
|
|
37
25
|
enumerable: true,
|
|
38
26
|
get: function () {
|
|
39
27
|
return _getEasing.default;
|
|
40
28
|
}
|
|
41
29
|
});
|
|
42
|
-
|
|
43
|
-
_Object$defineProperty(exports, "interpolate", {
|
|
30
|
+
Object.defineProperty(exports, "interpolate", {
|
|
44
31
|
enumerable: true,
|
|
45
32
|
get: function () {
|
|
46
33
|
return _interpolate.default;
|
|
47
34
|
}
|
|
48
35
|
});
|
|
49
|
-
|
|
50
|
-
_Object$defineProperty(exports, "presets", {
|
|
36
|
+
Object.defineProperty(exports, "presets", {
|
|
51
37
|
enumerable: true,
|
|
52
38
|
get: function () {
|
|
53
39
|
return _presets.default;
|
|
@@ -64,6 +50,8 @@ var _interpolate = _interopRequireDefault(require("./src/interpolate"));
|
|
|
64
50
|
|
|
65
51
|
var _presets = _interopRequireDefault(require("./src/presets"));
|
|
66
52
|
|
|
67
|
-
function
|
|
53
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
54
|
+
|
|
55
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
68
56
|
|
|
69
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor =
|
|
57
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/cjs/src/Animation.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = void 0;
|
|
12
7
|
|
|
13
|
-
var _now = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/date/now"));
|
|
14
|
-
|
|
15
|
-
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
16
|
-
|
|
17
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
18
|
-
|
|
19
|
-
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
|
|
20
|
-
|
|
21
|
-
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
22
|
-
|
|
23
8
|
var _Event = _interopRequireDefault(require("./utils/Event"));
|
|
24
9
|
|
|
25
10
|
var _shouldStopAnimation = _interopRequireDefault(require("./shouldStopAnimation"));
|
|
@@ -34,12 +19,14 @@ var _mapToZero = _interopRequireDefault(require("./mapToZero"));
|
|
|
34
19
|
|
|
35
20
|
var _wrapValue = _interopRequireDefault(require("./wrapValue"));
|
|
36
21
|
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
37
24
|
/* eslint-disable max-depth */
|
|
38
25
|
|
|
39
26
|
/* eslint-disable eqeqeq */
|
|
40
27
|
|
|
41
28
|
/* eslint-disable max-lines-per-function */
|
|
42
|
-
const now = () =>
|
|
29
|
+
const now = () => Date.now();
|
|
43
30
|
|
|
44
31
|
const msPerFrame = 1000 / 60;
|
|
45
32
|
/**
|
|
@@ -57,8 +44,8 @@ class Animation extends _Event.default {
|
|
|
57
44
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
58
45
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
59
46
|
super();
|
|
60
|
-
this._props =
|
|
61
|
-
this._config =
|
|
47
|
+
this._props = Object.assign({}, props);
|
|
48
|
+
this._config = Object.assign({}, config);
|
|
62
49
|
this.initStates();
|
|
63
50
|
}
|
|
64
51
|
|
|
@@ -66,7 +53,7 @@ class Animation extends _Event.default {
|
|
|
66
53
|
config = config && typeof config === 'object' ? config : this._config;
|
|
67
54
|
const ret = {};
|
|
68
55
|
|
|
69
|
-
for (const key of
|
|
56
|
+
for (const key of Object.keys(object)) {
|
|
70
57
|
ret[key] = (0, _wrapValue.default)(object[key], config);
|
|
71
58
|
}
|
|
72
59
|
|
|
@@ -83,19 +70,19 @@ class Animation extends _Event.default {
|
|
|
83
70
|
this._from = {};
|
|
84
71
|
|
|
85
72
|
if (from && typeof from) {
|
|
86
|
-
for (const key of
|
|
73
|
+
for (const key of Object.keys(from)) {
|
|
87
74
|
this._from[key] = typeof from[key] === 'object' && from[key].val ? from[key].val : from[key];
|
|
88
75
|
}
|
|
89
76
|
}
|
|
90
77
|
|
|
91
78
|
this._to = this._wrapConfig(to, config);
|
|
92
|
-
this._delay = (
|
|
79
|
+
this._delay = parseInt(config.delay) || 0;
|
|
93
80
|
const currentStyle = this._from && (0, _stripStyle.default)(this._from) || (0, _stripStyle.default)(this._to);
|
|
94
81
|
const currentVelocity = (0, _mapToZero.default)(currentStyle);
|
|
95
|
-
this._currentStyle =
|
|
96
|
-
this._currentVelocity =
|
|
97
|
-
this._lastIdealStyle =
|
|
98
|
-
this._lastIdealVelocity =
|
|
82
|
+
this._currentStyle = Object.assign({}, currentStyle);
|
|
83
|
+
this._currentVelocity = Object.assign({}, currentVelocity);
|
|
84
|
+
this._lastIdealStyle = Object.assign({}, currentStyle);
|
|
85
|
+
this._lastIdealVelocity = Object.assign({}, currentVelocity);
|
|
99
86
|
this.resetPlayStates();
|
|
100
87
|
this._frameCount = 0;
|
|
101
88
|
this._prevTime = 0;
|
|
@@ -112,7 +99,7 @@ class Animation extends _Event.default {
|
|
|
112
99
|
if ((0, _shouldStopAnimation.default)(this._currentStyle, this._to, this._currentVelocity, this._startedTime || nowTime, nowTime) || this._ended || this._stopped) {
|
|
113
100
|
if (this._wasAnimating && !this._ended && !this._stopped) {
|
|
114
101
|
// should emit reset in settimeout for delay msPerframe
|
|
115
|
-
this._timer = (
|
|
102
|
+
this._timer = setTimeout(() => {
|
|
116
103
|
clearTimeout(this._timer);
|
|
117
104
|
this._timer = null;
|
|
118
105
|
this._ended = true;
|
|
@@ -150,7 +137,7 @@ class Animation extends _Event.default {
|
|
|
150
137
|
const newLastIdealVelocity = {};
|
|
151
138
|
const newCurrentStyle = {};
|
|
152
139
|
const newCurrentVelocity = {};
|
|
153
|
-
const toKeys = this._to &&
|
|
140
|
+
const toKeys = this._to && Object.keys(this._to) || [];
|
|
154
141
|
|
|
155
142
|
for (const key of toKeys) {
|
|
156
143
|
const styleValue = this._to[key];
|
|
@@ -207,10 +194,10 @@ class Animation extends _Event.default {
|
|
|
207
194
|
}
|
|
208
195
|
|
|
209
196
|
this._timer = null;
|
|
210
|
-
this._currentStyle =
|
|
211
|
-
this._currentVelocity =
|
|
212
|
-
this._lastIdealStyle =
|
|
213
|
-
this._lastIdealVelocity =
|
|
197
|
+
this._currentStyle = Object.assign({}, newCurrentStyle);
|
|
198
|
+
this._currentVelocity = Object.assign({}, newCurrentVelocity);
|
|
199
|
+
this._lastIdealStyle = Object.assign({}, newLastIdealStyle);
|
|
200
|
+
this._lastIdealVelocity = Object.assign({}, newLastIdealVelocity); // console.log(newCurrentStyle);
|
|
214
201
|
|
|
215
202
|
if (!this._destroyed) {
|
|
216
203
|
this.emit('frame', this.getCurrentStates());
|
|
@@ -298,24 +285,24 @@ class Animation extends _Event.default {
|
|
|
298
285
|
|
|
299
286
|
reverse() {
|
|
300
287
|
this.destroy();
|
|
301
|
-
const props =
|
|
288
|
+
const props = Object.assign({}, this._props);
|
|
302
289
|
const [from, to] = [props.to, props.from];
|
|
303
290
|
props.from = from;
|
|
304
291
|
props.to = to;
|
|
305
|
-
this._props =
|
|
292
|
+
this._props = Object.assign({}, props);
|
|
306
293
|
this.initStates();
|
|
307
294
|
}
|
|
308
295
|
|
|
309
296
|
getCurrentStates() {
|
|
310
|
-
return
|
|
297
|
+
return Object.assign({}, this._currentStyle);
|
|
311
298
|
}
|
|
312
299
|
|
|
313
300
|
getInitialStates() {
|
|
314
|
-
return
|
|
301
|
+
return Object.assign({}, (0, _stripStyle.default)(this._props.from));
|
|
315
302
|
}
|
|
316
303
|
|
|
317
304
|
getFinalStates() {
|
|
318
|
-
return
|
|
305
|
+
return Object.assign({}, (0, _stripStyle.default)(this._props.to));
|
|
319
306
|
}
|
|
320
307
|
|
|
321
308
|
}
|
package/lib/cjs/src/constants.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.events = void 0;
|
|
10
7
|
const events = ['start', 'frame', 'pause', 'resume', 'stop', 'rest'];
|
|
11
8
|
exports.events = events;
|
package/lib/cjs/src/getEasing.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = getEasing;
|
|
12
7
|
exports.easingMap = void 0;
|
|
13
8
|
|
|
14
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
15
|
-
|
|
16
|
-
var _parseFloat2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-float"));
|
|
17
|
-
|
|
18
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
19
|
-
|
|
20
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
21
|
-
|
|
22
|
-
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
23
|
-
|
|
24
9
|
var _bezierEasing = _interopRequireDefault(require("bezier-easing"));
|
|
25
10
|
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
26
13
|
function minMax(val, min, max) {
|
|
27
14
|
return Math.min(Math.max(val, min), max);
|
|
28
15
|
}
|
|
29
16
|
|
|
30
17
|
function parseEasingParameters(string) {
|
|
31
|
-
var _context;
|
|
32
|
-
|
|
33
18
|
const match = /\(([^)]+)\)/.exec(string);
|
|
34
|
-
return match ?
|
|
19
|
+
return match ? match[1].split(',').map(p => parseFloat(p)) : [];
|
|
35
20
|
} // Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
|
|
36
21
|
|
|
37
22
|
|
|
@@ -110,10 +95,8 @@ const easingMap = (() => {
|
|
|
110
95
|
linear: [0.25, 0.25, 0.75, 0.75]
|
|
111
96
|
};
|
|
112
97
|
|
|
113
|
-
for (const coords of
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(0, _forEach.default)(_context2 = curves[coords]).call(_context2, (ease, i) => {
|
|
98
|
+
for (const coords of Object.keys(curves)) {
|
|
99
|
+
curves[coords].forEach((ease, i) => {
|
|
117
100
|
eases['ease' + coords + names[i]] = ease;
|
|
118
101
|
});
|
|
119
102
|
}
|
|
@@ -137,7 +120,7 @@ function getEasing(easing) {
|
|
|
137
120
|
if (!easing || typeof easing !== 'string') {
|
|
138
121
|
easing = 'linear';
|
|
139
122
|
} else {
|
|
140
|
-
easing =
|
|
123
|
+
easing = easing.trim();
|
|
141
124
|
}
|
|
142
125
|
|
|
143
126
|
let name = easing.split('(')[0];
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = interpolate;
|
|
12
7
|
|
|
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
8
|
/**
|
|
20
9
|
*
|
|
21
10
|
* @param {number|number[]|string|string[]} from
|
|
@@ -37,19 +26,19 @@ function interpolate(from, to) {
|
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
if (typeof from === 'string' || typeof from === 'number') {
|
|
40
|
-
from = [(
|
|
29
|
+
from = [parseFloat(from)];
|
|
41
30
|
}
|
|
42
31
|
|
|
43
32
|
if (typeof to === 'string' || typeof to === 'number') {
|
|
44
|
-
to = [(
|
|
33
|
+
to = [parseFloat(to)];
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
const result = [];
|
|
48
37
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
fromVal = (
|
|
52
|
-
const toVal = (
|
|
38
|
+
if (Array.isArray(from) && Array.isArray(to)) {
|
|
39
|
+
from.forEach((fromVal, idx) => {
|
|
40
|
+
fromVal = parseFloat(fromVal);
|
|
41
|
+
const toVal = parseFloat(to[idx]);
|
|
53
42
|
result.push((toVal - fromVal) * ratio + fromVal);
|
|
54
43
|
});
|
|
55
44
|
}
|
package/lib/cjs/src/mapToZero.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = mapToZero;
|
|
12
7
|
|
|
13
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
8
|
// currently used to initiate the velocity style object to 0
|
|
16
9
|
function mapToZero(obj) {
|
|
17
10
|
const ret = {};
|
|
18
|
-
const objKeys = obj &&
|
|
11
|
+
const objKeys = obj && Object.keys(obj) || [];
|
|
19
12
|
|
|
20
13
|
for (const key of objKeys) {
|
|
21
14
|
ret[key] = 0;
|
package/lib/cjs/src/presets.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = void 0;
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = shouldStopAnimation;
|
|
12
7
|
|
|
13
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
8
|
var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
|
|
16
9
|
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
17
12
|
/**
|
|
18
13
|
* usage assumption: currentStyle values have already been rendered but it says
|
|
19
14
|
* nothing of whether currentStyle is stale (see unreadPropStyle)
|
|
@@ -28,7 +23,7 @@ var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
|
|
|
28
23
|
*/
|
|
29
24
|
// eslint-disable-next-line max-len
|
|
30
25
|
function shouldStopAnimation(currentStyle, style, currentVelocity, startTime, nowTime) {
|
|
31
|
-
for (const key of
|
|
26
|
+
for (const key of Object.keys(style)) {
|
|
32
27
|
const styleValue = style[key];
|
|
33
28
|
const value = typeof styleValue === 'number' ? styleValue : styleValue.val;
|
|
34
29
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = shouldUseBezier;
|
|
10
7
|
|
|
11
8
|
function shouldUseBezier(config) {
|
package/lib/cjs/src/stepper.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = stepper;
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = stripStyle;
|
|
10
7
|
|
|
11
8
|
/* eslint-disable no-restricted-syntax */
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = void 0;
|
|
12
7
|
|
|
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
8
|
class Event {
|
|
24
9
|
constructor() {
|
|
25
|
-
this._eventMap = new
|
|
10
|
+
this._eventMap = new Map();
|
|
26
11
|
}
|
|
27
12
|
|
|
28
13
|
on(event, callback) {
|
|
@@ -54,11 +39,11 @@ class Event {
|
|
|
54
39
|
if (typeof callback === 'function') {
|
|
55
40
|
const callbacks = this._eventMap.get(event);
|
|
56
41
|
|
|
57
|
-
if (
|
|
42
|
+
if (Array.isArray(callbacks) && callbacks.length) {
|
|
58
43
|
let index = -1; // eslint-disable-next-line max-depth
|
|
59
44
|
|
|
60
|
-
while ((index =
|
|
61
|
-
|
|
45
|
+
while ((index = callbacks.findIndex(cb => cb === callback)) > -1) {
|
|
46
|
+
callbacks.splice(index, 1);
|
|
62
47
|
}
|
|
63
48
|
} // eslint-disable-next-line eqeqeq
|
|
64
49
|
|
|
@@ -71,8 +56,6 @@ class Event {
|
|
|
71
56
|
}
|
|
72
57
|
|
|
73
58
|
emit(event) {
|
|
74
|
-
var _context;
|
|
75
|
-
|
|
76
59
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
77
60
|
args[_key - 1] = arguments[_key];
|
|
78
61
|
}
|
|
@@ -81,7 +64,8 @@ class Event {
|
|
|
81
64
|
return false;
|
|
82
65
|
}
|
|
83
66
|
|
|
84
|
-
|
|
67
|
+
this._eventMap.get(event).forEach(callback => callback(...args));
|
|
68
|
+
|
|
85
69
|
return true;
|
|
86
70
|
}
|
|
87
71
|
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = debounce;
|
|
12
7
|
|
|
13
|
-
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
14
|
-
|
|
15
8
|
/**
|
|
16
9
|
*
|
|
17
10
|
* @param {Function} func
|
|
@@ -28,6 +21,6 @@ function debounce(func) {
|
|
|
28
21
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
29
22
|
const context = this;
|
|
30
23
|
clearTimeout(timeoutId);
|
|
31
|
-
timeoutId = (
|
|
24
|
+
timeoutId = setTimeout(() => func.apply(context, args), delay);
|
|
32
25
|
};
|
|
33
26
|
}
|
package/lib/cjs/src/utils/log.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = void 0;
|
|
10
7
|
|
|
11
8
|
const log = function (text) {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = noop;
|
|
10
7
|
|
|
11
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
6
|
exports.default = shallowEqual;
|
|
10
7
|
|
|
11
8
|
/* eslint-disable no-restricted-syntax */
|
package/lib/cjs/src/wrapValue.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = wrapValue;
|
|
12
7
|
|
|
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
8
|
var _getEasing = _interopRequireDefault(require("./getEasing"));
|
|
18
9
|
|
|
19
10
|
var _presets = _interopRequireDefault(require("./presets"));
|
|
20
11
|
|
|
21
12
|
var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
|
|
22
13
|
|
|
23
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const defaultConfig = Object.assign(Object.assign({}, _presets.default.default), {
|
|
24
17
|
precision: 0.01
|
|
25
18
|
});
|
|
26
19
|
|
|
@@ -30,29 +23,29 @@ function wrapValue(val) {
|
|
|
30
23
|
if ((0, _shouldUseBezier.default)(config)) {
|
|
31
24
|
const easing = (0, _getEasing.default)(config.easing);
|
|
32
25
|
const duration = typeof config.duration === 'number' && config.duration > 0 ? config.duration : 1000;
|
|
33
|
-
config =
|
|
26
|
+
config = Object.assign(Object.assign({}, config), {
|
|
34
27
|
easing,
|
|
35
28
|
duration
|
|
36
29
|
});
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
let wrapped =
|
|
32
|
+
let wrapped = Object.assign(Object.assign(Object.assign({}, defaultConfig), config), {
|
|
40
33
|
done: false
|
|
41
34
|
});
|
|
42
35
|
|
|
43
36
|
if (val && typeof val === 'object' && 'val' in val) {
|
|
44
37
|
if ((0, _shouldUseBezier.default)(val)) {
|
|
45
38
|
const easing = (0, _getEasing.default)(val.easing);
|
|
46
|
-
const duration = typeof val.duration === 'number' && val.duration > 0 ? val.duration : (
|
|
47
|
-
val =
|
|
39
|
+
const duration = typeof val.duration === 'number' && val.duration > 0 ? val.duration : parseInt(config.duration) || 1000;
|
|
40
|
+
val = Object.assign(Object.assign({}, val), {
|
|
48
41
|
easing,
|
|
49
42
|
duration
|
|
50
43
|
});
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
wrapped =
|
|
46
|
+
wrapped = Object.assign(Object.assign({}, wrapped), val);
|
|
54
47
|
} else {
|
|
55
|
-
wrapped =
|
|
48
|
+
wrapped = Object.assign(Object.assign({}, wrapped), {
|
|
56
49
|
val
|
|
57
50
|
});
|
|
58
51
|
}
|
package/lib/es/src/Animation.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import _Date$now from "@babel/runtime-corejs3/core-js-stable/date/now";
|
|
2
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
5
|
-
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
6
|
-
|
|
7
1
|
/* eslint-disable max-depth */
|
|
8
2
|
|
|
9
3
|
/* eslint-disable eqeqeq */
|
|
@@ -17,7 +11,7 @@ import stepper from './stepper';
|
|
|
17
11
|
import mapToZero from './mapToZero';
|
|
18
12
|
import wrapValue from './wrapValue';
|
|
19
13
|
|
|
20
|
-
const now = () =>
|
|
14
|
+
const now = () => Date.now();
|
|
21
15
|
|
|
22
16
|
const msPerFrame = 1000 / 60;
|
|
23
17
|
/**
|
|
@@ -35,8 +29,8 @@ export default class Animation extends Event {
|
|
|
35
29
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
30
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
31
|
super();
|
|
38
|
-
this._props =
|
|
39
|
-
this._config =
|
|
32
|
+
this._props = Object.assign({}, props);
|
|
33
|
+
this._config = Object.assign({}, config);
|
|
40
34
|
this.initStates();
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -44,7 +38,7 @@ export default class Animation extends Event {
|
|
|
44
38
|
config = config && typeof config === 'object' ? config : this._config;
|
|
45
39
|
const ret = {};
|
|
46
40
|
|
|
47
|
-
for (const key of
|
|
41
|
+
for (const key of Object.keys(object)) {
|
|
48
42
|
ret[key] = wrapValue(object[key], config);
|
|
49
43
|
}
|
|
50
44
|
|
|
@@ -61,19 +55,19 @@ export default class Animation extends Event {
|
|
|
61
55
|
this._from = {};
|
|
62
56
|
|
|
63
57
|
if (from && typeof from) {
|
|
64
|
-
for (const key of
|
|
58
|
+
for (const key of Object.keys(from)) {
|
|
65
59
|
this._from[key] = typeof from[key] === 'object' && from[key].val ? from[key].val : from[key];
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
this._to = this._wrapConfig(to, config);
|
|
70
|
-
this._delay =
|
|
64
|
+
this._delay = parseInt(config.delay) || 0;
|
|
71
65
|
const currentStyle = this._from && stripStyle(this._from) || stripStyle(this._to);
|
|
72
66
|
const currentVelocity = mapToZero(currentStyle);
|
|
73
|
-
this._currentStyle =
|
|
74
|
-
this._currentVelocity =
|
|
75
|
-
this._lastIdealStyle =
|
|
76
|
-
this._lastIdealVelocity =
|
|
67
|
+
this._currentStyle = Object.assign({}, currentStyle);
|
|
68
|
+
this._currentVelocity = Object.assign({}, currentVelocity);
|
|
69
|
+
this._lastIdealStyle = Object.assign({}, currentStyle);
|
|
70
|
+
this._lastIdealVelocity = Object.assign({}, currentVelocity);
|
|
77
71
|
this.resetPlayStates();
|
|
78
72
|
this._frameCount = 0;
|
|
79
73
|
this._prevTime = 0;
|
|
@@ -90,7 +84,7 @@ export default class Animation extends Event {
|
|
|
90
84
|
if (shouldStopAnimation(this._currentStyle, this._to, this._currentVelocity, this._startedTime || nowTime, nowTime) || this._ended || this._stopped) {
|
|
91
85
|
if (this._wasAnimating && !this._ended && !this._stopped) {
|
|
92
86
|
// should emit reset in settimeout for delay msPerframe
|
|
93
|
-
this._timer =
|
|
87
|
+
this._timer = setTimeout(() => {
|
|
94
88
|
clearTimeout(this._timer);
|
|
95
89
|
this._timer = null;
|
|
96
90
|
this._ended = true;
|
|
@@ -128,7 +122,7 @@ export default class Animation extends Event {
|
|
|
128
122
|
const newLastIdealVelocity = {};
|
|
129
123
|
const newCurrentStyle = {};
|
|
130
124
|
const newCurrentVelocity = {};
|
|
131
|
-
const toKeys = this._to &&
|
|
125
|
+
const toKeys = this._to && Object.keys(this._to) || [];
|
|
132
126
|
|
|
133
127
|
for (const key of toKeys) {
|
|
134
128
|
const styleValue = this._to[key];
|
|
@@ -185,10 +179,10 @@ export default class Animation extends Event {
|
|
|
185
179
|
}
|
|
186
180
|
|
|
187
181
|
this._timer = null;
|
|
188
|
-
this._currentStyle =
|
|
189
|
-
this._currentVelocity =
|
|
190
|
-
this._lastIdealStyle =
|
|
191
|
-
this._lastIdealVelocity =
|
|
182
|
+
this._currentStyle = Object.assign({}, newCurrentStyle);
|
|
183
|
+
this._currentVelocity = Object.assign({}, newCurrentVelocity);
|
|
184
|
+
this._lastIdealStyle = Object.assign({}, newLastIdealStyle);
|
|
185
|
+
this._lastIdealVelocity = Object.assign({}, newLastIdealVelocity); // console.log(newCurrentStyle);
|
|
192
186
|
|
|
193
187
|
if (!this._destroyed) {
|
|
194
188
|
this.emit('frame', this.getCurrentStates());
|
|
@@ -276,26 +270,24 @@ export default class Animation extends Event {
|
|
|
276
270
|
|
|
277
271
|
reverse() {
|
|
278
272
|
this.destroy();
|
|
279
|
-
|
|
280
|
-
const props = _Object$assign({}, this._props);
|
|
281
|
-
|
|
273
|
+
const props = Object.assign({}, this._props);
|
|
282
274
|
const [from, to] = [props.to, props.from];
|
|
283
275
|
props.from = from;
|
|
284
276
|
props.to = to;
|
|
285
|
-
this._props =
|
|
277
|
+
this._props = Object.assign({}, props);
|
|
286
278
|
this.initStates();
|
|
287
279
|
}
|
|
288
280
|
|
|
289
281
|
getCurrentStates() {
|
|
290
|
-
return
|
|
282
|
+
return Object.assign({}, this._currentStyle);
|
|
291
283
|
}
|
|
292
284
|
|
|
293
285
|
getInitialStates() {
|
|
294
|
-
return
|
|
286
|
+
return Object.assign({}, stripStyle(this._props.from));
|
|
295
287
|
}
|
|
296
288
|
|
|
297
289
|
getFinalStates() {
|
|
298
|
-
return
|
|
290
|
+
return Object.assign({}, stripStyle(this._props.to));
|
|
299
291
|
}
|
|
300
292
|
|
|
301
293
|
}
|
package/lib/es/src/getEasing.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
2
|
-
import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
5
|
-
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
|
|
6
1
|
import bezier from 'bezier-easing';
|
|
7
2
|
|
|
8
3
|
function minMax(val, min, max) {
|
|
@@ -10,10 +5,8 @@ function minMax(val, min, max) {
|
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
function parseEasingParameters(string) {
|
|
13
|
-
var _context;
|
|
14
|
-
|
|
15
8
|
const match = /\(([^)]+)\)/.exec(string);
|
|
16
|
-
return match ?
|
|
9
|
+
return match ? match[1].split(',').map(p => parseFloat(p)) : [];
|
|
17
10
|
} // Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
|
|
18
11
|
|
|
19
12
|
|
|
@@ -92,10 +85,8 @@ export const easingMap = (() => {
|
|
|
92
85
|
linear: [0.25, 0.25, 0.75, 0.75]
|
|
93
86
|
};
|
|
94
87
|
|
|
95
|
-
for (const coords of
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_forEachInstanceProperty(_context2 = curves[coords]).call(_context2, (ease, i) => {
|
|
88
|
+
for (const coords of Object.keys(curves)) {
|
|
89
|
+
curves[coords].forEach((ease, i) => {
|
|
99
90
|
eases['ease' + coords + names[i]] = ease;
|
|
100
91
|
});
|
|
101
92
|
}
|
|
@@ -116,7 +107,7 @@ export default function getEasing(easing) {
|
|
|
116
107
|
if (!easing || typeof easing !== 'string') {
|
|
117
108
|
easing = 'linear';
|
|
118
109
|
} else {
|
|
119
|
-
easing =
|
|
110
|
+
easing = easing.trim();
|
|
120
111
|
}
|
|
121
112
|
|
|
122
113
|
let name = easing.split('(')[0];
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
|
|
2
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
3
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
*
|
|
7
3
|
* @param {number|number[]|string|string[]} from
|
|
@@ -23,21 +19,19 @@ export default function interpolate(from, to) {
|
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
if (typeof from === 'string' || typeof from === 'number') {
|
|
26
|
-
from = [
|
|
22
|
+
from = [parseFloat(from)];
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
if (typeof to === 'string' || typeof to === 'number') {
|
|
30
|
-
to = [
|
|
26
|
+
to = [parseFloat(to)];
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
const result = [];
|
|
34
30
|
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
fromVal =
|
|
38
|
-
|
|
39
|
-
const toVal = _parseFloat(to[idx]);
|
|
40
|
-
|
|
31
|
+
if (Array.isArray(from) && Array.isArray(to)) {
|
|
32
|
+
from.forEach((fromVal, idx) => {
|
|
33
|
+
fromVal = parseFloat(fromVal);
|
|
34
|
+
const toVal = parseFloat(to[idx]);
|
|
41
35
|
result.push((toVal - fromVal) * ratio + fromVal);
|
|
42
36
|
});
|
|
43
37
|
}
|
package/lib/es/src/mapToZero.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
2
1
|
// currently used to initiate the velocity style object to 0
|
|
3
2
|
export default function mapToZero(obj) {
|
|
4
3
|
const ret = {};
|
|
5
|
-
const objKeys = obj &&
|
|
4
|
+
const objKeys = obj && Object.keys(obj) || [];
|
|
6
5
|
|
|
7
6
|
for (const key of objKeys) {
|
|
8
7
|
ret[key] = 0;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
2
1
|
import shouldUseBezier from './shouldUseBezier';
|
|
3
2
|
/**
|
|
4
3
|
* usage assumption: currentStyle values have already been rendered but it says
|
|
@@ -15,7 +14,7 @@ import shouldUseBezier from './shouldUseBezier';
|
|
|
15
14
|
// eslint-disable-next-line max-len
|
|
16
15
|
|
|
17
16
|
export default function shouldStopAnimation(currentStyle, style, currentVelocity, startTime, nowTime) {
|
|
18
|
-
for (const key of
|
|
17
|
+
for (const key of Object.keys(style)) {
|
|
19
18
|
const styleValue = style[key];
|
|
20
19
|
const value = typeof styleValue === 'number' ? styleValue : styleValue.val;
|
|
21
20
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
2
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
3
|
-
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
4
|
-
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
6
1
|
export default class Event {
|
|
7
2
|
constructor() {
|
|
8
|
-
this._eventMap = new
|
|
3
|
+
this._eventMap = new Map();
|
|
9
4
|
}
|
|
10
5
|
|
|
11
6
|
on(event, callback) {
|
|
@@ -37,11 +32,11 @@ export default class Event {
|
|
|
37
32
|
if (typeof callback === 'function') {
|
|
38
33
|
const callbacks = this._eventMap.get(event);
|
|
39
34
|
|
|
40
|
-
if (
|
|
35
|
+
if (Array.isArray(callbacks) && callbacks.length) {
|
|
41
36
|
let index = -1; // eslint-disable-next-line max-depth
|
|
42
37
|
|
|
43
|
-
while ((index =
|
|
44
|
-
|
|
38
|
+
while ((index = callbacks.findIndex(cb => cb === callback)) > -1) {
|
|
39
|
+
callbacks.splice(index, 1);
|
|
45
40
|
}
|
|
46
41
|
} // eslint-disable-next-line eqeqeq
|
|
47
42
|
|
|
@@ -54,8 +49,6 @@ export default class Event {
|
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
emit(event) {
|
|
57
|
-
var _context;
|
|
58
|
-
|
|
59
52
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
60
53
|
args[_key - 1] = arguments[_key];
|
|
61
54
|
}
|
|
@@ -64,7 +57,7 @@ export default class Event {
|
|
|
64
57
|
return false;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
this._eventMap.get(event).forEach(callback => callback(...args));
|
|
68
61
|
|
|
69
62
|
return true;
|
|
70
63
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* @param {Function} func
|
|
@@ -16,6 +14,6 @@ export default function debounce(func) {
|
|
|
16
14
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
17
15
|
const context = this;
|
|
18
16
|
clearTimeout(timeoutId);
|
|
19
|
-
timeoutId =
|
|
17
|
+
timeoutId = setTimeout(() => func.apply(context, args), delay);
|
|
20
18
|
};
|
|
21
19
|
}
|
package/lib/es/src/wrapValue.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
|
-
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
3
1
|
import getEasing from './getEasing';
|
|
4
2
|
import presets from './presets';
|
|
5
3
|
import shouldUseBezier from './shouldUseBezier';
|
|
6
|
-
|
|
7
|
-
const defaultConfig = _Object$assign(_Object$assign({}, presets.default), {
|
|
4
|
+
const defaultConfig = Object.assign(Object.assign({}, presets.default), {
|
|
8
5
|
precision: 0.01
|
|
9
6
|
});
|
|
10
|
-
|
|
11
7
|
export default function wrapValue(val) {
|
|
12
8
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
9
|
|
|
14
10
|
if (shouldUseBezier(config)) {
|
|
15
11
|
const easing = getEasing(config.easing);
|
|
16
12
|
const duration = typeof config.duration === 'number' && config.duration > 0 ? config.duration : 1000;
|
|
17
|
-
config =
|
|
13
|
+
config = Object.assign(Object.assign({}, config), {
|
|
18
14
|
easing,
|
|
19
15
|
duration
|
|
20
16
|
});
|
|
21
17
|
}
|
|
22
18
|
|
|
23
|
-
let wrapped =
|
|
19
|
+
let wrapped = Object.assign(Object.assign(Object.assign({}, defaultConfig), config), {
|
|
24
20
|
done: false
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
if (val && typeof val === 'object' && 'val' in val) {
|
|
28
24
|
if (shouldUseBezier(val)) {
|
|
29
25
|
const easing = getEasing(val.easing);
|
|
30
|
-
const duration = typeof val.duration === 'number' && val.duration > 0 ? val.duration :
|
|
31
|
-
val =
|
|
26
|
+
const duration = typeof val.duration === 'number' && val.duration > 0 ? val.duration : parseInt(config.duration) || 1000;
|
|
27
|
+
val = Object.assign(Object.assign({}, val), {
|
|
32
28
|
easing,
|
|
33
29
|
duration
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
wrapped =
|
|
33
|
+
wrapped = Object.assign(Object.assign({}, wrapped), val);
|
|
38
34
|
} else {
|
|
39
|
-
wrapped =
|
|
35
|
+
wrapped = Object.assign(Object.assign({}, wrapped), {
|
|
40
36
|
val
|
|
41
37
|
});
|
|
42
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-animation",
|
|
3
|
-
"version": "2.19.0
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "animation base library for semi-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animation",
|
|
@@ -30,11 +30,9 @@
|
|
|
30
30
|
"prepublishOnly": "npm run build:lib"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@babel/runtime-corejs3": "^7.15.4",
|
|
34
33
|
"bezier-easing": "^2.1.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
|
-
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
38
36
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
39
37
|
"@babel/preset-env": "^7.15.8",
|
|
40
38
|
"del": "^6.0.0",
|
|
@@ -44,5 +42,5 @@
|
|
|
44
42
|
"merge2": "^1.4.1",
|
|
45
43
|
"react-storybook-addon-props-combinations": "^1.1.0"
|
|
46
44
|
},
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c0ef56c31a5c13adb050fbdb611e51da881f0cb8"
|
|
48
46
|
}
|