@douyinfe/semi-animation 2.0.7 → 2.1.0-alpha.2

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.
@@ -31,9 +31,7 @@ const msPerFrame = 1000 / 60;
31
31
  */
32
32
 
33
33
  export default class Animation extends Event {
34
- constructor() {
35
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
+ constructor(props = {}, config = {}) {
37
35
  super();
38
36
  this._props = _Object$assign({}, props);
39
37
  this._config = _Object$assign({}, config);
@@ -17,9 +17,7 @@ function parseEasingParameters(string) {
17
17
  } // Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
18
18
 
19
19
 
20
- function elastic() {
21
- let amplitude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
22
- let period = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
20
+ function elastic(amplitude = 1, period = 0.5) {
23
21
  const a = minMax(amplitude, 1, 10);
24
22
  const p = minMax(period, 0.1, 2);
25
23
  return t => t === 0 || t === 1 ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1 - p / (Math.PI * 2) * Math.asin(1 / a)) * (Math.PI * 2) / p);
@@ -12,11 +12,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
12
12
  * @returns {any}
13
13
  */
14
14
  // eslint-disable-next-line max-len
15
- export default function interpolate(from, to) {
16
- let ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
17
- let parser = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
18
- let formatter = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
19
-
15
+ export default function interpolate(from, to, ratio = 0, parser = null, formatter = null) {
20
16
  if (typeof parser === 'function') {
21
17
  from = parser(from);
22
18
  to = parser(to);
@@ -19,13 +19,10 @@ export default class Event {
19
19
  }
20
20
 
21
21
  once(event, callback) {
22
- var _this = this;
23
-
24
22
  if (event && typeof callback === 'function') {
25
- const fn = function () {
26
- callback(...arguments);
27
-
28
- _this.off(event, fn);
23
+ const fn = (...args) => {
24
+ callback(...args);
25
+ this.off(event, fn);
29
26
  };
30
27
 
31
28
  this.on(event, fn);
@@ -53,13 +50,9 @@ export default class Event {
53
50
  return this;
54
51
  }
55
52
 
56
- emit(event) {
53
+ emit(event, ...args) {
57
54
  var _context;
58
55
 
59
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
60
- args[_key - 1] = arguments[_key];
61
- }
62
-
63
56
  if (!this._eventMap.has(event)) {
64
57
  return false;
65
58
  }
@@ -5,14 +5,9 @@ import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
5
5
  * @param {Function} func
6
6
  * @param {number} delay
7
7
  */
8
- export default function debounce(func) {
9
- let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
8
+ export default function debounce(func, delay = 0) {
10
9
  let timeoutId;
11
- return function () {
12
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13
- args[_key] = arguments[_key];
14
- }
15
-
10
+ return function (...args) {
16
11
  // eslint-disable-next-line @typescript-eslint/no-this-alias
17
12
  const context = this;
18
13
  clearTimeout(timeoutId);
@@ -1,9 +1,5 @@
1
- const log = function (text) {
1
+ const log = (text, ...rest) => {
2
2
  if (process.env.NODE_ENV === 'development') {
3
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4
- rest[_key - 1] = arguments[_key];
5
- }
6
-
7
3
  console.log(text, ...rest);
8
4
  }
9
5
  };
@@ -8,9 +8,7 @@ const defaultConfig = _Object$assign(_Object$assign({}, presets.default), {
8
8
  precision: 0.01
9
9
  });
10
10
 
11
- export default function wrapValue(val) {
12
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
-
11
+ export default function wrapValue(val, config = {}) {
14
12
  if (shouldUseBezier(config)) {
15
13
  const easing = getEasing(config.easing);
16
14
  const duration = typeof config.duration === 'number' && config.duration > 0 ? config.duration : 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-animation",
3
- "version": "2.0.7",
3
+ "version": "2.1.0-alpha.2",
4
4
  "description": "animation base library for semi-ui",
5
5
  "keywords": [
6
6
  "animation",
@@ -44,5 +44,5 @@
44
44
  "merge2": "^1.4.1",
45
45
  "react-storybook-addon-props-combinations": "^1.1.0"
46
46
  },
47
- "gitHead": "624c0747ef24bdf26b8c478aa474d105adc24285"
47
+ "gitHead": "50381484f8df8aaa00285cf0a2ee01edf0083115"
48
48
  }