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

59 lines
1.3 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 { withTracker } 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 {
render() {
const { cursorX, cursorY } = this.props;
if (cursorX > 0 && cursorY > 0) {
return (
<Cursor
cursorX={cursorX}
cursorY={cursorY}
setLabelBoxDimensions={this.setLabelBoxDimensions}
{...this.props}
/>
);
}
return null;
}
}
export default withTracker((params) => {
2017-08-15 08:15:11 +08:00
const { cursorId } = params;
2017-08-15 08:15:11 +08:00
const cursor = CursorService.getCurrentCursor(cursorId);
if (cursor) {
2018-07-27 03:05:55 +08:00
const { xPercent: cursorX, yPercent: cursorY, userName } = cursor;
const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
return {
cursorX,
cursorY,
userName,
isRTL,
};
}
return {
cursorX: -1,
cursorY: -1,
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,
};