x-star-design 0.0.11 → 0.0.12

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,4 +31,8 @@ export interface AcAnimationProps {
31
31
  * @default offsetX: 0, offsetY: 0, fontSize: 36, fontFamily: 'Arial', shadowColor: 'rgba(2,38,121,0.2)', color: '#022679' 相对canvas水平垂直居中
32
32
  */
33
33
  titleStyle?: titleShowProps;
34
+ /**
35
+ * @description canvas卸载时的回调
36
+ */
37
+ onFinish?: () => void;
34
38
  }
@@ -8,7 +8,8 @@ var AcAnimation = function AcAnimation(_ref) {
8
8
  offsetX: 0,
9
9
  offsetY: 0
10
10
  } : _ref$imgSizeAndPositi,
11
- titleStyle = _ref.titleStyle;
11
+ titleStyle = _ref.titleStyle,
12
+ onFinish = _ref.onFinish;
12
13
  var canvas = document.createElement('canvas');
13
14
  var ctx = canvas.getContext('2d');
14
15
  var AnimationID = -1;
@@ -107,6 +108,11 @@ var AcAnimation = function AcAnimation(_ref) {
107
108
  });
108
109
  }
109
110
  };
111
+ var shutDownCanvas = function shutDownCanvas() {
112
+ canvas.remove();
113
+ window.cancelAnimationFrame(AnimationID);
114
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
115
+ };
110
116
 
111
117
  //---------Render-----------
112
118
  var render = function render() {
@@ -152,8 +158,7 @@ var AcAnimation = function AcAnimation(_ref) {
152
158
  ctx.setTransform(1, 0, 0, 1, 0, 0);
153
159
  });
154
160
  if (confetti.length <= 10) {
155
- canvas.remove();
156
- window.cancelAnimationFrame(AnimationID);
161
+ shutDownCanvas();
157
162
  return;
158
163
  }
159
164
  AnimationID = window.requestAnimationFrame(render);
@@ -172,8 +177,7 @@ var AcAnimation = function AcAnimation(_ref) {
172
177
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
173
178
  id: "ac-canvas",
174
179
  onClick: function onClick() {
175
- canvas.remove();
176
- window.cancelAnimationFrame(AnimationID);
180
+ shutDownCanvas();
177
181
  }
178
182
  }));
179
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-design",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "A react component library developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",