1 | var _class, _temp;
|
2 |
|
3 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4 |
|
5 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
6 |
|
7 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
8 |
|
9 | import React, { Component } from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import Instance from './instance.js';
|
12 |
|
13 | var LotteryWheel = (_temp = _class = function (_Component) {
|
14 | _inherits(LotteryWheel, _Component);
|
15 |
|
16 | function LotteryWheel(props) {
|
17 | _classCallCheck(this, LotteryWheel);
|
18 |
|
19 | return _possibleConstructorReturn(this, _Component.call(this, props));
|
20 | }
|
21 |
|
22 | LotteryWheel.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
23 | if (JSON.stringify(prevProps.data) !== JSON.stringify(this.props.data)) {
|
24 | this.instance.params.data = this.props.data;
|
25 | this.instance.init();
|
26 | }
|
27 | };
|
28 |
|
29 | LotteryWheel.prototype.componentDidMount = function componentDidMount() {
|
30 | if (this.instance) return;
|
31 | var instance = new Instance(this.$el, {
|
32 |
|
33 | spacing: this.props.spacing,
|
34 |
|
35 | data: this.props.data,
|
36 |
|
37 | font: this.props.font,
|
38 | fontTop: this.props.fontTop,
|
39 | fontFillStyle: this.props.fontFillStyle,
|
40 |
|
41 | bgFillStyle: this.props.bgFillStyle,
|
42 | bgStrokeStyle: this.props.bgStrokeStyle,
|
43 | bgLineWidth: this.props.bgLineWidth,
|
44 |
|
45 | iconWidth: this.props.iconWidth,
|
46 | iconHeight: this.props.iconHeight,
|
47 | iconTop: this.props.iconTop,
|
48 |
|
49 | around: this.props.around,
|
50 |
|
51 | suffix: this.props.suffix,
|
52 | quality: this.props.quality
|
53 | });
|
54 | this.instance = instance;
|
55 | };
|
56 |
|
57 | LotteryWheel.prototype.render = function render() {
|
58 | var _this2 = this;
|
59 |
|
60 | var _props = this.props,
|
61 | width = _props.width,
|
62 | height = _props.height,
|
63 | className = _props.className,
|
64 | style = _props.style;
|
65 |
|
66 | return React.createElement(
|
67 | 'canvas',
|
68 | { ref: function ref(el) {
|
69 | _this2.$el = el;
|
70 | }, width: width, height: height, className: className, style: style },
|
71 | 'Canvas\u62BD\u5956\u8F6E\u76D8'
|
72 | );
|
73 | };
|
74 |
|
75 | return LotteryWheel;
|
76 | }(Component), _class.defaultProps = {}, _temp);
|
77 | export { LotteryWheel as default };
|
78 | LotteryWheel.propTypes = process.env.NODE_ENV !== "production" ? {
|
79 |
|
80 | data: PropTypes.array,
|
81 |
|
82 | fontFamily: PropTypes.string,
|
83 | fontSize: PropTypes.number,
|
84 | fontTop: PropTypes.number,
|
85 | fontFillStyle: PropTypes.string,
|
86 |
|
87 | bgFillStyle: PropTypes.string,
|
88 | bgStrokeStyle: PropTypes.string,
|
89 | bgLineWidth: PropTypes.number,
|
90 |
|
91 | iconWidth: PropTypes.number,
|
92 | iconHeight: PropTypes.number,
|
93 | iconTop: PropTypes.number,
|
94 |
|
95 | around: PropTypes.number,
|
96 |
|
97 | width: PropTypes.number,
|
98 | height: PropTypes.number,
|
99 | style: PropTypes.object,
|
100 | className: PropTypes.string,
|
101 |
|
102 | spacing: PropTypes.number,
|
103 |
|
104 | suffix: PropTypes.string,
|
105 | quality: PropTypes.number
|
106 | } : {}; |
\ | No newline at end of file |