Moved presentation overlays' rendering to a separate function

This commit is contained in:
Oleksandr Zhurbenko 2017-09-18 16:54:52 -07:00
parent ff4e7bffd0
commit 838382b6f9
3 changed files with 38 additions and 20 deletions

View File

@ -211,26 +211,7 @@ export default class PresentationArea extends React.Component {
slideHeight={height}
/>
</g>
{this.props.userIsPresenter || this.props.multiUser ?
<PresentationOverlayContainer
slideWidth={width}
slideHeight={height}
getSvgRef={this.getSvgRef}
>
<WhiteboardOverlayContainer
getSvgRef={this.getSvgRef}
whiteboardId={slideObj.id}
slideWidth={width}
slideHeight={height}
viewBoxX={x}
viewBoxY={y}
viewBoxWidth={viewBoxWidth}
viewBoxHeight={viewBoxHeight}
physicalSlideWidth={(adjustedSizes.width / slideObj.widthRatio) * 100}
physicalSlideHeight={(adjustedSizes.height / slideObj.heightRatio) * 100}
/>
</PresentationOverlayContainer>
: null }
{this.renderOverlays(slideObj, adjustedSizes)}
</svg>
</CSSTransitionGroup>
</div>
@ -239,6 +220,43 @@ export default class PresentationArea extends React.Component {
return null;
}
renderOverlays(slideObj, adjustedSizes) {
if (!this.props.userIsPresenter && !this.props.multiUser) {
return null;
}
// retrieving the pre-calculated data from the slide object
const {
x,
y,
width,
height,
viewBoxWidth,
viewBoxHeight,
} = slideObj.calculatedData;
return (
<PresentationOverlayContainer
slideWidth={width}
slideHeight={height}
getSvgRef={this.getSvgRef}
>
<WhiteboardOverlayContainer
getSvgRef={this.getSvgRef}
whiteboardId={slideObj.id}
slideWidth={width}
slideHeight={height}
viewBoxX={x}
viewBoxY={y}
viewBoxWidth={viewBoxWidth}
viewBoxHeight={viewBoxHeight}
physicalSlideWidth={(adjustedSizes.width / slideObj.widthRatio) * 100}
physicalSlideHeight={(adjustedSizes.height / slideObj.heightRatio) * 100}
/>
</PresentationOverlayContainer>
);
}
renderPresentationToolbar() {
if (this.props.currentSlide) {
return (