bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/component.jsx

126 lines
3.8 KiB
React
Raw Normal View History

import React, { PropTypes } from 'react';
2017-02-23 08:10:30 +08:00
import ShapeGroupContainer from '../whiteboard/shape-group/container.jsx';
2016-07-16 04:45:54 +08:00
import Cursor from './cursor/component.jsx';
import PresentationToolbarContainer from './presentation-toolbar/container.jsx';
import Slide from './slide/component.jsx';
import styles from './styles.scss';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import PollingContainer from '/imports/ui/components/polling/container';
import PresentationOverlayContainer from './presentation-overlay/container';
2017-02-17 05:11:46 +08:00
export default class PresentationArea extends React.Component {
constructor(props) {
super(props);
}
2017-02-17 05:11:46 +08:00
renderPresentationArea() {
let slideObj = this.props.currentSlide;
2016-07-27 04:56:43 +08:00
if (this.props.currentSlide) {
slideObj = this.props.currentSlide.slide;
2016-06-25 05:30:37 +08:00
let x = -slideObj.x_offset * 2 * slideObj.width / 100;
let y = -slideObj.y_offset * 2 * slideObj.height / 100;
let viewBoxWidth = slideObj.width * slideObj.width_ratio / 100;
let viewBoxHeight = slideObj.height * slideObj.height_ratio / 100;
return (
2016-06-03 06:09:28 +08:00
<ReactCSSTransitionGroup
transitionName={ {
enter: styles.enter,
enterActive: styles.enterActive,
appear: styles.appear,
appearActive: styles.appearActive,
} }
transitionAppear={true}
transitionEnter={true}
transitionLeave={false}
transitionAppearTimeout={400}
transitionEnterTimeout={400}
transitionLeaveTimeout={400}
>
2016-06-03 06:09:28 +08:00
<svg
2016-06-25 05:30:37 +08:00
viewBox={`${x} ${y} ${viewBoxWidth} ${viewBoxHeight}`}
2016-06-03 06:09:28 +08:00
version="1.1"
2016-07-06 05:49:31 +08:00
//it's supposed to be here in theory
//but now it's ignored by all the browsers and it's not supported by React
//xmlNS="http://www.w3.org/2000/svg"
2016-06-03 06:09:28 +08:00
className={styles.svgStyles}
key={slideObj.id}
>
<defs>
<clipPath id="viewBox">
<rect x={x} y={y} width="100%" height="100%" fill="none"/>
</clipPath>
</defs>
<g clipPath="url(#viewBox)">
2016-07-27 04:56:43 +08:00
<Slide id="slideComponent" currentSlide={this.props.currentSlide}/>
2017-02-23 08:10:30 +08:00
<ShapeGroupContainer
width = {slideObj.width}
height = {slideObj.height}
whiteboardId = {slideObj.id}
/>
{this.props.cursor ?
<Cursor
2016-07-16 04:45:54 +08:00
viewBoxWidth={viewBoxWidth}
viewBoxHeight={viewBoxHeight}
viewBoxX={x}
viewBoxY={y}
widthRatio={slideObj.width_ratio}
cursorX={this.props.cursor.x}
cursorY={this.props.cursor.y}
/>
: null }
</g>
2017-02-07 08:10:50 +08:00
{this.props.userIsPresenter ?
<PresentationOverlayContainer
2017-02-07 08:10:50 +08:00
x={x}
y={y}
vbwidth={viewBoxWidth}
vbheight={viewBoxHeight}
/>
: null }
2016-06-03 06:09:28 +08:00
</svg>
</ReactCSSTransitionGroup>
);
} else {
return null;
}
}
renderPresentationToolbar() {
2016-08-06 02:39:24 +08:00
if (this.props.currentSlide) {
return (
<PresentationToolbarContainer
2016-08-06 02:39:24 +08:00
currentSlideNum={this.props.currentSlide.slide.num}
presentationId={this.props.currentSlide.presentationId}
/>
);
} else {
return null;
}
}
render() {
return (
2017-02-17 05:11:46 +08:00
<div className={styles.presentationContainer}>
<div className={styles.presentationWrapper}>
<div className={styles.presentationPaper}>
{this.renderPresentationArea()}
</div>
2016-06-30 06:00:06 +08:00
</div>
<PollingContainer />
{this.renderPresentationToolbar()}
</div>
);
}
}
2017-02-17 05:11:46 +08:00
PresentationArea.defaultProps = {
svgProps: {
2016-06-03 06:09:28 +08:00
},
svgStyle: {
2016-06-03 06:09:28 +08:00
},
};