2017-06-04 10:40:14 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-06-05 07:20:38 +08:00
|
|
|
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';
|
2016-07-08 01:08:26 +08:00
|
|
|
import PollingContainer from '/imports/ui/components/polling/container';
|
2017-07-01 03:16:00 +08:00
|
|
|
import ShapeGroupContainer from '../whiteboard/shape-group/container';
|
|
|
|
import Cursor from './cursor/component';
|
|
|
|
import PresentationToolbarContainer from './presentation-toolbar/container';
|
|
|
|
import Slide from './slide/component';
|
|
|
|
import styles from './styles.scss';
|
2016-05-31 06:07:02 +08:00
|
|
|
|
2017-02-17 05:11:46 +08:00
|
|
|
export default class PresentationArea extends React.Component {
|
2016-05-31 06:07:02 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-06-02 07:37:51 +08:00
|
|
|
}
|
|
|
|
|
2017-02-17 05:11:46 +08:00
|
|
|
renderPresentationArea() {
|
2016-06-27 22:48:17 +08:00
|
|
|
let slideObj = this.props.currentSlide;
|
2016-07-27 04:56:43 +08:00
|
|
|
|
2016-06-27 22:48:17 +08:00
|
|
|
if (this.props.currentSlide) {
|
2017-07-25 01:50:44 +08:00
|
|
|
slideObj = this.props.currentSlide;
|
|
|
|
const x = -slideObj.xOffset * 2 * slideObj.width / 100;
|
|
|
|
const y = -slideObj.yOffset * 2 * slideObj.height / 100;
|
|
|
|
const viewBoxWidth = slideObj.width * slideObj.widthRatio / 100;
|
|
|
|
const viewBoxHeight = slideObj.height * slideObj.heightRatio / 100;
|
2016-06-02 07:37:51 +08:00
|
|
|
return (
|
2017-06-05 07:20:38 +08:00
|
|
|
<CSSTransitionGroup
|
2017-06-03 03:25:02 +08:00
|
|
|
transitionName={{
|
2016-06-03 06:09:28 +08:00
|
|
|
enter: styles.enter,
|
|
|
|
enterActive: styles.enterActive,
|
|
|
|
appear: styles.appear,
|
|
|
|
appearActive: styles.appearActive,
|
2017-06-03 03:25:02 +08:00
|
|
|
}}
|
|
|
|
transitionAppear
|
|
|
|
transitionEnter
|
2016-06-03 06:09:28 +08:00
|
|
|
transitionLeave={false}
|
|
|
|
transitionAppearTimeout={400}
|
|
|
|
transitionEnterTimeout={400}
|
|
|
|
transitionLeaveTimeout={400}
|
2016-06-02 07:37:51 +08:00
|
|
|
>
|
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
|
|
|
|
2017-06-03 03:25:02 +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}
|
2016-06-05 07:09:50 +08:00
|
|
|
key={slideObj.id}
|
2016-05-31 06:07:02 +08:00
|
|
|
>
|
2016-06-10 03:00:44 +08:00
|
|
|
<defs>
|
|
|
|
<clipPath id="viewBox">
|
2017-06-03 03:25:02 +08:00
|
|
|
<rect x={x} y={y} width="100%" height="100%" fill="none" />
|
2016-06-10 03:00:44 +08:00
|
|
|
</clipPath>
|
|
|
|
</defs>
|
|
|
|
<g clipPath="url(#viewBox)">
|
2017-06-03 03:25:02 +08:00
|
|
|
<Slide id="slideComponent" currentSlide={this.props.currentSlide} />
|
2017-02-23 08:10:30 +08:00
|
|
|
<ShapeGroupContainer
|
2017-06-03 03:25:02 +08:00
|
|
|
width={slideObj.width}
|
|
|
|
height={slideObj.height}
|
|
|
|
whiteboardId={slideObj.id}
|
2017-02-23 08:10:30 +08:00
|
|
|
/>
|
2016-08-21 10:59:32 +08:00
|
|
|
{this.props.cursor ?
|
|
|
|
<Cursor
|
2017-06-03 03:25:02 +08:00
|
|
|
viewBoxWidth={viewBoxWidth}
|
|
|
|
viewBoxHeight={viewBoxHeight}
|
|
|
|
viewBoxX={x}
|
|
|
|
viewBoxY={y}
|
2017-07-25 01:50:44 +08:00
|
|
|
widthRatio={slideObj.widthRatio}
|
2017-06-03 03:25:02 +08:00
|
|
|
cursorX={this.props.cursor.x}
|
|
|
|
cursorY={this.props.cursor.y}
|
2016-08-21 10:59:32 +08:00
|
|
|
/>
|
|
|
|
: null }
|
2016-06-10 03:00:44 +08:00
|
|
|
</g>
|
2016-06-03 06:09:28 +08:00
|
|
|
</svg>
|
2017-06-05 07:20:38 +08:00
|
|
|
</CSSTransitionGroup>
|
2016-06-02 07:37:51 +08:00
|
|
|
);
|
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
return null;
|
2016-06-02 07:37:51 +08:00
|
|
|
}
|
|
|
|
|
2017-02-24 04:20:21 +08:00
|
|
|
renderPresentationToolbar() {
|
2016-08-06 02:39:24 +08:00
|
|
|
if (this.props.currentSlide) {
|
|
|
|
return (
|
2017-02-24 04:20:21 +08:00
|
|
|
<PresentationToolbarContainer
|
2017-07-25 01:50:44 +08:00
|
|
|
currentSlideNum={this.props.currentSlide.num}
|
2016-08-06 02:39:24 +08:00
|
|
|
presentationId={this.props.currentSlide.presentationId}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
return null;
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 07:37:51 +08:00
|
|
|
render() {
|
|
|
|
return (
|
2017-02-17 05:11:46 +08:00
|
|
|
<div className={styles.presentationContainer}>
|
|
|
|
<div className={styles.presentationWrapper}>
|
|
|
|
<div className={styles.presentationPaper}>
|
|
|
|
{this.renderPresentationArea()}
|
2016-07-01 06:21:46 +08:00
|
|
|
</div>
|
2016-06-30 06:00:06 +08:00
|
|
|
</div>
|
|
|
|
<PollingContainer />
|
2017-02-24 04:20:21 +08:00
|
|
|
{this.renderPresentationToolbar()}
|
2016-05-31 06:07:02 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 05:11:46 +08:00
|
|
|
PresentationArea.defaultProps = {
|
2016-05-31 06:07:02 +08:00
|
|
|
svgProps: {
|
2016-06-03 06:09:28 +08:00
|
|
|
|
2016-05-31 06:07:02 +08:00
|
|
|
},
|
|
|
|
svgStyle: {
|
2016-06-03 06:09:28 +08:00
|
|
|
|
2016-05-31 06:07:02 +08:00
|
|
|
},
|
|
|
|
};
|