mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
38 lines
662 B
JavaScript
38 lines
662 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default class WindowSystem extends React.Component {
|
|
|
|
constructor() {
|
|
super();
|
|
this.moveHandler = null;
|
|
}
|
|
|
|
componentDidMount() {
|
|
document.body.onmousemove = e => {
|
|
if (this.moveHandler !== null) {
|
|
this.moveHandler(e);
|
|
}
|
|
};
|
|
}
|
|
|
|
componentWillUnMount() {
|
|
}
|
|
|
|
render() {
|
|
return this.props.children;
|
|
}
|
|
|
|
childContext = {
|
|
setWindowMoveHandler: moveHandler => this.moveHandler = moveHandler
|
|
};
|
|
|
|
getChildContext() {
|
|
return this.childContext;
|
|
}
|
|
|
|
static childContextTypes = {
|
|
setWindowMoveHandler: PropTypes.func
|
|
}
|
|
|
|
}
|