bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/cursor/container.jsx

76 lines
1.7 KiB
React
Raw Normal View History

2017-06-08 05:25:47 +08:00
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { createContainer } from 'meteor/react-meteor-data';
import CursorService from './service';
import Cursor from './component';
2017-08-15 08:15:11 +08:00
class CursorContainer extends Component {
constructor() {
super();
this.state = {
labelBoxWidth: 0,
labelBoxHeight: 0,
};
this.setLabelBoxDimensions = this.setLabelBoxDimensions.bind(this);
}
2017-08-15 08:15:11 +08:00
setLabelBoxDimensions(labelBoxWidth, labelBoxHeight) {
this.setState({
labelBoxWidth,
labelBoxHeight,
});
}
render() {
const { cursorX, cursorY } = this.props;
2017-09-06 09:36:15 +08:00
const { labelBoxWidth, labelBoxHeight } = this.state;
2017-08-15 08:15:11 +08:00
if (cursorX > 0 && cursorY > 0) {
return (
<Cursor
cursorX={cursorX}
cursorY={cursorY}
2017-09-06 09:36:15 +08:00
labelBoxWidth={labelBoxWidth}
labelBoxHeight={labelBoxHeight}
2017-08-15 08:15:11 +08:00
setLabelBoxDimensions={this.setLabelBoxDimensions}
{...this.props}
/>
);
}
return null;
}
}
2017-08-15 08:15:11 +08:00
export default createContainer((params) => {
const { cursorId } = params;
2017-08-15 08:15:11 +08:00
const cursor = CursorService.getCurrentCursor(cursorId);
let cursorX = -1;
let cursorY = -1;
2017-08-15 08:15:11 +08:00
let userName = '';
if (cursor) {
cursorX = cursor.x;
cursorY = cursor.y;
2017-08-15 08:15:11 +08:00
userName = cursor.userName;
}
return {
cursorX,
cursorY,
2017-08-15 08:15:11 +08:00
userName,
};
}, CursorContainer);
CursorContainer.propTypes = {
// Defines the 'x' coordinate for the cursor, in percentages of the slide's width
cursorX: PropTypes.number.isRequired,
// Defines the 'y' coordinate for the cursor, in percentages of the slide's height
cursorY: PropTypes.number.isRequired,
};