-
Notifications
You must be signed in to change notification settings - Fork 6
/
player.js
218 lines (165 loc) · 7.1 KB
/
player.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
webpackJsonp([1],{
/***/ 419:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}return target;
};
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
}
}return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
};
}();
var _react = __webpack_require__(0);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(11);
var _reactDom2 = _interopRequireDefault(_reactDom);
var _reactRedux = __webpack_require__(6);
var _appStateHoc = __webpack_require__(23);
var _appStateHoc2 = _interopRequireDefault(_appStateHoc);
var _controls = __webpack_require__(27);
var _controls2 = _interopRequireDefault(_controls);
var _stage = __webpack_require__(43);
var _stage2 = _interopRequireDefault(_stage);
var _box = __webpack_require__(7);
var _box2 = _interopRequireDefault(_box);
var _gui = __webpack_require__(24);
var _gui2 = _interopRequireDefault(_gui);
var _projectLoaderHoc = __webpack_require__(28);
var _projectLoaderHoc2 = _interopRequireDefault(_projectLoaderHoc);
__webpack_require__(420);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}return call && ((typeof call === 'undefined' ? 'undefined' : _typeof(call)) === "object" || typeof call === "function") ? call : self;
}
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 === 'undefined' ? 'undefined' : _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;
}
var mapStateToProps = function mapStateToProps(state) {
return { vm: state.vm };
};
var VMStage = (0, _reactRedux.connect)(mapStateToProps)(_stage2.default);
var VMControls = (0, _reactRedux.connect)(mapStateToProps)(_controls2.default);
var Player = function (_React$Component) {
_inherits(Player, _React$Component);
function Player(props) {
_classCallCheck(this, Player);
var _this = _possibleConstructorReturn(this, (Player.__proto__ || Object.getPrototypeOf(Player)).call(this, props));
_this.handleResize = _this.handleResize.bind(_this);
_this.state = _this.getWindowSize();
return _this;
}
_createClass(Player, [{
key: 'componentDidMount',
value: function componentDidMount() {
window.addEventListener('resize', this.handleResize);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
}, {
key: 'getWindowSize',
value: function getWindowSize() {
return {
width: window.innerWidth,
height: window.innerHeight
};
}
}, {
key: 'handleResize',
value: function handleResize() {
this.setState(this.getWindowSize());
}
}, {
key: 'render',
value: function render() {
var height = this.state.height - 40;
var width = height + height / 3;
if (width > this.state.width) {
width = this.state.width;
height = width * .75;
}
return _react2.default.createElement(_gui2.default, _extends({}, this.props, {
style: {
margin: '0 auto'
},
width: width
}), _react2.default.createElement(_box2.default, { height: 40 }, _react2.default.createElement(VMControls, {
style: {
marginRight: 10,
height: 40
}
})), _react2.default.createElement(VMStage, {
height: height,
width: width
}));
}
}]);
return Player;
}(_react2.default.Component);
var App = (0, _appStateHoc2.default)((0, _projectLoaderHoc2.default)(Player));
var appTarget = document.createElement('div');
document.body.appendChild(appTarget);
_reactDom2.default.render(_react2.default.createElement(App, null), appTarget);
/***/ }),
/***/ 420:
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(421);
if(typeof content === 'string') content = [[module.i, content, '']];
// Prepare cssTransformation
var transform;
var options = {"hmr":true}
options.transform = transform
// add the styles to the DOM
var update = __webpack_require__(3)(content, options);
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../../node_modules/css-loader/index.js??ref--1-1!../../node_modules/postcss-loader/lib/index.js??postcss!./player.css", function() {
var newContent = require("!!../../node_modules/css-loader/index.js??ref--1-1!../../node_modules/postcss-loader/lib/index.js??postcss!./player.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/***/ 421:
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(2)(undefined);
// imports
// module
exports.push([module.i, "body {\n padding: 0;\n margin: 0;\n}\n", ""]);
// exports
/***/ })
},[419]);
//# sourceMappingURL=player.js.map