2020-01-17 21:20:03 +08:00
|
|
|
import React, { PureComponent, Fragment } from 'react';
|
2019-07-10 07:11:48 +08:00
|
|
|
import Draggable from 'react-draggable';
|
2019-03-01 05:39:57 +08:00
|
|
|
import cx from 'classnames';
|
2019-07-24 06:24:31 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2019-07-30 03:42:11 +08:00
|
|
|
import Resizable from 're-resizable';
|
2020-01-11 04:20:26 +08:00
|
|
|
import { isMobile, isIPad13 } from 'react-device-detect';
|
2020-06-16 23:20:24 +08:00
|
|
|
import _ from 'lodash';
|
2020-01-17 21:20:03 +08:00
|
|
|
import { withDraggableConsumer } from './context';
|
2019-07-10 07:11:48 +08:00
|
|
|
import VideoProviderContainer from '/imports/ui/components/video-provider/container';
|
2019-06-20 04:55:43 +08:00
|
|
|
import { styles } from '../styles.scss';
|
2019-07-10 07:11:48 +08:00
|
|
|
import Storage from '../../../services/storage/session';
|
2020-04-23 22:07:44 +08:00
|
|
|
import { withLayoutConsumer } from '/imports/ui/components/layout/context';
|
2020-06-05 07:01:17 +08:00
|
|
|
import { WEBCAMSAREA_MIN_PERCENT, PRESENTATIONAREA_MIN_WIDTH } from '/imports/ui/components/layout/layout-manager';
|
2019-03-01 05:39:57 +08:00
|
|
|
|
2020-01-11 04:20:26 +08:00
|
|
|
const BROWSER_ISMOBILE = isMobile || isIPad13;
|
2019-03-25 22:43:02 +08:00
|
|
|
|
2019-07-24 06:24:31 +08:00
|
|
|
const propTypes = {
|
|
|
|
swapLayout: PropTypes.bool,
|
|
|
|
hideOverlay: PropTypes.bool,
|
|
|
|
disableVideo: PropTypes.bool,
|
|
|
|
audioModalIsOpen: PropTypes.bool,
|
|
|
|
webcamDraggableState: PropTypes.objectOf(Object).isRequired,
|
|
|
|
webcamDraggableDispatch: PropTypes.func.isRequired,
|
|
|
|
refMediaContainer: PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
swapLayout: false,
|
|
|
|
hideOverlay: false,
|
|
|
|
disableVideo: false,
|
|
|
|
audioModalIsOpen: false,
|
|
|
|
refMediaContainer: null,
|
|
|
|
};
|
|
|
|
|
2020-01-17 21:20:03 +08:00
|
|
|
class WebcamDraggable extends PureComponent {
|
2019-03-01 05:39:57 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
const { layoutContextState } = props;
|
|
|
|
const { webcamsPlacement, mediaBounds } = layoutContextState;
|
|
|
|
this.state = {
|
|
|
|
webcamsAreaResizable: {
|
|
|
|
width: webcamsPlacement === 'top' || webcamsPlacement === 'bottom' ? mediaBounds.width : mediaBounds.width * WEBCAMSAREA_MIN_PERCENT,
|
|
|
|
height: webcamsPlacement === 'left' || webcamsPlacement === 'right' ? mediaBounds.height : mediaBounds.height * WEBCAMSAREA_MIN_PERCENT,
|
|
|
|
},
|
|
|
|
resizing: false,
|
|
|
|
};
|
|
|
|
|
2019-03-01 05:39:57 +08:00
|
|
|
this.handleWebcamDragStart = this.handleWebcamDragStart.bind(this);
|
|
|
|
this.handleWebcamDragStop = this.handleWebcamDragStop.bind(this);
|
2019-07-30 23:03:29 +08:00
|
|
|
this.onFullscreenChange = this.onFullscreenChange.bind(this);
|
2019-09-18 02:25:28 +08:00
|
|
|
this.onResizeStop = this.onResizeStop.bind(this);
|
2019-12-11 05:43:22 +08:00
|
|
|
this.onResizeStart = this.onResizeStart.bind(this);
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2019-07-30 23:03:29 +08:00
|
|
|
document.addEventListener('fullscreenchange', this.onFullscreenChange);
|
2020-07-16 00:44:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
2020-06-05 07:01:17 +08:00
|
|
|
const { layoutContextState } = this.props;
|
2020-06-20 13:46:10 +08:00
|
|
|
const { webcamsAreaSize } = layoutContextState;
|
|
|
|
if ((webcamsAreaSize.width !== prevProps.layoutContextState.webcamsAreaSize.width
|
|
|
|
|| webcamsAreaSize.height !== prevProps.layoutContextState.webcamsAreaSize.height)) {
|
2020-04-23 22:07:44 +08:00
|
|
|
this.setWebcamsAreaResizable(webcamsAreaSize.width, webcamsAreaSize.height);
|
2020-07-16 00:44:59 +08:00
|
|
|
}
|
2019-07-10 07:11:48 +08:00
|
|
|
}
|
2019-06-25 02:37:17 +08:00
|
|
|
|
2019-07-30 23:03:29 +08:00
|
|
|
componentWillUnmount() {
|
2020-07-16 00:44:59 +08:00
|
|
|
window.removeEventListener('resize', this.debouncedOnResize);
|
2019-07-30 23:03:29 +08:00
|
|
|
document.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFullscreenChange() {
|
|
|
|
this.forceUpdate();
|
|
|
|
}
|
|
|
|
|
2019-12-11 05:43:22 +08:00
|
|
|
onResizeStart() {
|
2020-06-20 13:46:10 +08:00
|
|
|
const { layoutContextDispatch } = this.props;
|
|
|
|
|
2019-12-11 05:43:22 +08:00
|
|
|
this.setState({ resizing: true });
|
2020-06-20 13:46:10 +08:00
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setWebcamsAreaResizing',
|
|
|
|
value: true,
|
|
|
|
},
|
|
|
|
);
|
2019-12-11 05:43:22 +08:00
|
|
|
}
|
|
|
|
|
2020-06-16 23:20:24 +08:00
|
|
|
onResizeHandle(resizableWidth, resizableHeight) {
|
|
|
|
const { webcamsAreaResizable } = this.state;
|
|
|
|
const { layoutContextState, layoutContextDispatch } = this.props;
|
|
|
|
const { webcamsPlacement, webcamsAreaSize } = layoutContextState;
|
|
|
|
|
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setAutoArrangeLayout',
|
|
|
|
value: false,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
const newWebcamsAreaResizable = {
|
|
|
|
width: Math.trunc(webcamsAreaResizable.width) + resizableWidth,
|
|
|
|
height: Math.trunc(webcamsAreaResizable.height) + resizableHeight,
|
|
|
|
};
|
2020-06-17 07:00:44 +08:00
|
|
|
|
2020-06-20 13:46:10 +08:00
|
|
|
const newWidth = webcamsPlacement === 'top' || webcamsPlacement === 'bottom' ? webcamsAreaSize.width : newWebcamsAreaResizable.width;
|
|
|
|
const newHeight = webcamsPlacement === 'left' || webcamsPlacement === 'right' ? webcamsAreaSize.height : newWebcamsAreaResizable.height;
|
2020-06-16 23:20:24 +08:00
|
|
|
|
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setTempWebcamsAreaSize',
|
|
|
|
value: {
|
2020-06-20 13:46:10 +08:00
|
|
|
width: newWidth,
|
|
|
|
height: newHeight,
|
2020-06-16 23:20:24 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2020-06-20 13:46:10 +08:00
|
|
|
|
2020-06-16 23:20:24 +08:00
|
|
|
window.dispatchEvent(new Event('webcamAreaResize'));
|
|
|
|
}
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
onResizeStop(resizableWidth, resizableHeight) {
|
|
|
|
const { webcamsAreaResizable } = this.state;
|
|
|
|
const { layoutContextState, layoutContextDispatch } = this.props;
|
|
|
|
const { webcamsPlacement, webcamsAreaSize } = layoutContextState;
|
2020-07-16 00:44:59 +08:00
|
|
|
|
2020-06-16 23:20:24 +08:00
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setWebcamsAreaResizing',
|
|
|
|
value: false,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
const newWebcamsAreaResizable = {
|
|
|
|
width: Math.trunc(webcamsAreaResizable.width) + resizableWidth,
|
|
|
|
height: Math.trunc(webcamsAreaResizable.height) + resizableHeight,
|
|
|
|
};
|
2020-04-23 22:07:44 +08:00
|
|
|
|
2020-05-01 06:18:03 +08:00
|
|
|
if (webcamsPlacement === 'top' || webcamsPlacement === 'bottom') {
|
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setWebcamsAreaUserSetsHeight',
|
|
|
|
value: newWebcamsAreaResizable.height,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (webcamsPlacement === 'right' || webcamsPlacement === 'left') {
|
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setWebcamsAreaUserSetsWidth',
|
2020-05-08 05:27:00 +08:00
|
|
|
value: newWebcamsAreaResizable.width,
|
2020-05-01 06:18:03 +08:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-20 13:46:10 +08:00
|
|
|
const newWidth = webcamsPlacement === 'top' || webcamsPlacement === 'bottom'
|
|
|
|
? webcamsAreaSize.width
|
|
|
|
: newWebcamsAreaResizable.width;
|
|
|
|
const newHeight = webcamsPlacement === 'left' || webcamsPlacement === 'right'
|
|
|
|
? webcamsAreaSize.height
|
|
|
|
: newWebcamsAreaResizable.height;
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setWebcamsAreaSize',
|
|
|
|
value: {
|
2020-06-20 13:46:10 +08:00
|
|
|
width: newWidth,
|
|
|
|
height: newHeight,
|
2020-05-01 06:18:03 +08:00
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
},
|
|
|
|
);
|
2019-03-01 05:39:57 +08:00
|
|
|
|
2020-06-20 13:46:10 +08:00
|
|
|
this.setWebcamsAreaResizable(newWidth, newHeight);
|
2019-03-01 05:39:57 +08:00
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
setTimeout(() => this.setState({ resizing: false }), 500);
|
|
|
|
window.dispatchEvent(new Event('webcamAreaResize'));
|
|
|
|
}
|
2020-07-16 00:44:59 +08:00
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
setWebcamsAreaResizable(width, height) {
|
|
|
|
this.setState({
|
|
|
|
webcamsAreaResizable: { width, height },
|
|
|
|
});
|
2020-07-16 00:44:59 +08:00
|
|
|
}
|
2020-07-06 20:58:50 +08:00
|
|
|
|
2019-07-10 07:11:48 +08:00
|
|
|
getWebcamsListBounds() {
|
2019-12-06 02:01:23 +08:00
|
|
|
const { webcamDraggableState } = this.props;
|
2019-07-10 07:11:48 +08:00
|
|
|
const { videoListRef } = webcamDraggableState;
|
|
|
|
if (videoListRef) {
|
|
|
|
const videoListRefRect = videoListRef.getBoundingClientRect();
|
2019-03-01 05:39:57 +08:00
|
|
|
const {
|
2019-07-10 07:11:48 +08:00
|
|
|
top, left, width, height,
|
|
|
|
} = videoListRefRect;
|
|
|
|
return {
|
2020-04-23 22:07:44 +08:00
|
|
|
top,
|
|
|
|
left,
|
|
|
|
width,
|
|
|
|
height,
|
2019-07-10 07:11:48 +08:00
|
|
|
};
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
2019-07-10 07:11:48 +08:00
|
|
|
return false;
|
2019-06-11 02:25:55 +08:00
|
|
|
}
|
|
|
|
|
2020-07-16 00:44:59 +08:00
|
|
|
calculatePosition() {
|
2020-04-23 22:07:44 +08:00
|
|
|
const { layoutContextState } = this.props;
|
|
|
|
const { mediaBounds } = layoutContextState;
|
|
|
|
|
|
|
|
const { top: mediaTop, left: mediaLeft } = mediaBounds;
|
2019-07-10 07:11:48 +08:00
|
|
|
const { top: webcamsListTop, left: webcamsListLeft } = this.getWebcamsListBounds();
|
|
|
|
const x = webcamsListLeft - mediaLeft;
|
|
|
|
const y = webcamsListTop - mediaTop;
|
|
|
|
return {
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
};
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
|
|
|
|
2019-12-06 02:01:23 +08:00
|
|
|
handleWebcamDragStart() {
|
|
|
|
const { webcamDraggableDispatch } = this.props;
|
|
|
|
const { x, y } = this.calculatePosition();
|
2019-07-10 07:11:48 +08:00
|
|
|
webcamDraggableDispatch({ type: 'dragStart' });
|
|
|
|
webcamDraggableDispatch(
|
|
|
|
{
|
|
|
|
type: 'setTempPosition',
|
|
|
|
value: {
|
2019-12-06 02:01:23 +08:00
|
|
|
x,
|
2019-07-10 07:11:48 +08:00
|
|
|
y,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
|
|
|
|
2019-12-06 02:01:23 +08:00
|
|
|
handleWebcamDragStop(e) {
|
2020-04-23 22:07:44 +08:00
|
|
|
const { webcamDraggableDispatch, layoutContextDispatch } = this.props;
|
2019-08-06 05:17:39 +08:00
|
|
|
const targetClassname = JSON.stringify(e.target.className);
|
2019-11-26 00:38:00 +08:00
|
|
|
|
2020-06-05 07:01:17 +08:00
|
|
|
layoutContextDispatch(
|
|
|
|
{
|
|
|
|
type: 'setAutoArrangeLayout',
|
|
|
|
value: false,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2019-11-01 05:11:26 +08:00
|
|
|
if (targetClassname) {
|
|
|
|
if (targetClassname.includes('Top')) {
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: 'setWebcamsPlacement',
|
|
|
|
value: 'top',
|
|
|
|
});
|
2019-11-26 00:38:00 +08:00
|
|
|
} else if (targetClassname.includes('Right')) {
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: 'setWebcamsPlacement',
|
|
|
|
value: 'right',
|
|
|
|
});
|
2019-11-01 05:11:26 +08:00
|
|
|
} else if (targetClassname.includes('Bottom')) {
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: 'setWebcamsPlacement',
|
|
|
|
value: 'bottom',
|
|
|
|
});
|
2019-11-26 00:38:00 +08:00
|
|
|
} else if (targetClassname.includes('Left')) {
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: 'setWebcamsPlacement',
|
|
|
|
value: 'left',
|
|
|
|
});
|
2019-11-01 05:11:26 +08:00
|
|
|
}
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
2019-07-10 07:11:48 +08:00
|
|
|
webcamDraggableDispatch({ type: 'dragEnd' });
|
2020-06-20 13:46:10 +08:00
|
|
|
window.dispatchEvent(new Event('webcamPlacementChange'));
|
2019-03-01 05:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextState,
|
2019-07-10 07:11:48 +08:00
|
|
|
webcamDraggableState,
|
2019-03-01 05:39:57 +08:00
|
|
|
swapLayout,
|
|
|
|
hideOverlay,
|
|
|
|
disableVideo,
|
2019-05-28 06:18:26 +08:00
|
|
|
audioModalIsOpen,
|
2019-03-01 05:39:57 +08:00
|
|
|
} = this.props;
|
2019-06-25 23:40:57 +08:00
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
const { resizing, webcamsAreaResizable } = this.state;
|
|
|
|
|
2020-06-20 13:46:10 +08:00
|
|
|
const {
|
|
|
|
mediaBounds,
|
|
|
|
webcamsAreaSize,
|
|
|
|
} = layoutContextState;
|
2019-12-11 05:43:22 +08:00
|
|
|
|
2019-12-06 02:01:23 +08:00
|
|
|
const {
|
|
|
|
dragging,
|
|
|
|
isCameraFullscreen,
|
|
|
|
optimalGrid,
|
|
|
|
} = webcamDraggableState;
|
2020-01-17 21:20:03 +08:00
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
const webcamsPlacement = Storage.getItem('webcamsPlacement');
|
2020-01-17 21:20:03 +08:00
|
|
|
|
2019-07-10 07:11:48 +08:00
|
|
|
const lastPosition = Storage.getItem('webcamLastPosition') || { x: 0, y: 0 };
|
2020-01-17 21:20:03 +08:00
|
|
|
|
2019-07-10 07:11:48 +08:00
|
|
|
let position = lastPosition;
|
2019-06-25 23:40:57 +08:00
|
|
|
|
2019-07-10 07:11:48 +08:00
|
|
|
if (dragging) {
|
|
|
|
position = webcamDraggableState.tempPosition;
|
2019-12-06 02:01:23 +08:00
|
|
|
} else if (!dragging) {
|
2019-07-10 07:11:48 +08:00
|
|
|
position = webcamDraggableState.lastPosition;
|
|
|
|
} else {
|
|
|
|
position = {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
};
|
|
|
|
}
|
2019-06-08 04:45:54 +08:00
|
|
|
|
2019-07-27 03:42:39 +08:00
|
|
|
if (swapLayout || isCameraFullscreen || BROWSER_ISMOBILE) {
|
2019-07-10 07:11:48 +08:00
|
|
|
position = {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
};
|
2019-06-08 04:45:54 +08:00
|
|
|
}
|
|
|
|
|
2019-07-10 07:11:48 +08:00
|
|
|
const {
|
|
|
|
width: mediaWidth,
|
|
|
|
height: mediaHeight,
|
2020-04-23 22:07:44 +08:00
|
|
|
} = mediaBounds;
|
2019-03-01 05:39:57 +08:00
|
|
|
|
|
|
|
const {
|
2019-07-10 07:11:48 +08:00
|
|
|
width: webcamsWidth,
|
|
|
|
height: webcamsHeight,
|
|
|
|
} = this.getWebcamsListBounds();
|
|
|
|
|
|
|
|
const isOverflowWidth = (lastPosition.x + webcamsWidth) > mediaWidth;
|
|
|
|
const isOverflowHeight = (lastPosition.y + webcamsHeight) > mediaHeight;
|
|
|
|
|
|
|
|
position = {
|
|
|
|
x: isOverflowWidth
|
2019-12-06 02:01:23 +08:00
|
|
|
&& !dragging && !swapLayout ? mediaWidth - webcamsWidth : position.x,
|
2019-07-10 07:11:48 +08:00
|
|
|
y: isOverflowHeight
|
2019-12-06 02:01:23 +08:00
|
|
|
&& !dragging && !swapLayout ? mediaHeight - (webcamsHeight + 1) : position.y,
|
2019-07-10 07:11:48 +08:00
|
|
|
};
|
2019-03-01 05:39:57 +08:00
|
|
|
|
|
|
|
const contentClassName = cx({
|
|
|
|
[styles.content]: true,
|
2019-11-26 00:38:00 +08:00
|
|
|
[styles.fullWidth]: swapLayout,
|
|
|
|
[styles.fullHeight]: swapLayout,
|
2019-03-01 05:39:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const overlayClassName = cx({
|
|
|
|
[styles.overlay]: true,
|
|
|
|
[styles.hideOverlay]: hideOverlay,
|
2019-12-03 04:21:34 +08:00
|
|
|
[styles.floatingOverlay]: dragging,
|
2019-12-06 02:01:23 +08:00
|
|
|
[styles.autoWidth]: dragging,
|
2020-04-23 22:07:44 +08:00
|
|
|
[styles.overlayToTop]: webcamsPlacement === 'top' && !dragging,
|
|
|
|
[styles.overlayToRight]: webcamsPlacement === 'right' && !dragging,
|
|
|
|
[styles.overlayToBottom]: webcamsPlacement === 'bottom' && !dragging,
|
|
|
|
[styles.overlayToLeft]: webcamsPlacement === 'left' && !dragging,
|
2019-03-01 05:39:57 +08:00
|
|
|
[styles.dragging]: dragging,
|
|
|
|
});
|
|
|
|
|
|
|
|
const dropZoneTopClassName = cx({
|
|
|
|
[styles.dropZoneTop]: true,
|
2019-07-10 07:11:48 +08:00
|
|
|
[styles.show]: dragging,
|
|
|
|
[styles.hide]: !dragging,
|
2019-07-27 03:42:39 +08:00
|
|
|
[styles.cursorGrabbing]: dragging && !isCameraFullscreen,
|
2019-03-01 05:39:57 +08:00
|
|
|
});
|
|
|
|
|
2019-11-26 00:38:00 +08:00
|
|
|
const dropZoneLeftClassName = cx({
|
|
|
|
[styles.dropZoneLeft]: true,
|
|
|
|
[styles.show]: dragging,
|
|
|
|
[styles.hide]: !dragging,
|
|
|
|
[styles.cursorGrabbing]: dragging && !isCameraFullscreen,
|
|
|
|
});
|
|
|
|
|
2019-03-01 05:39:57 +08:00
|
|
|
const dropZoneBottomClassName = cx({
|
|
|
|
[styles.dropZoneBottom]: true,
|
2019-07-10 07:11:48 +08:00
|
|
|
[styles.show]: dragging,
|
|
|
|
[styles.hide]: !dragging,
|
2019-07-27 03:42:39 +08:00
|
|
|
[styles.cursorGrabbing]: dragging && !isCameraFullscreen,
|
2019-03-01 05:39:57 +08:00
|
|
|
});
|
|
|
|
|
2019-11-26 00:38:00 +08:00
|
|
|
const dropZoneRightClassName = cx({
|
|
|
|
[styles.dropZoneRight]: true,
|
|
|
|
[styles.show]: dragging,
|
|
|
|
[styles.hide]: !dragging,
|
|
|
|
[styles.cursorGrabbing]: dragging && !isCameraFullscreen,
|
|
|
|
});
|
|
|
|
|
2019-03-01 05:39:57 +08:00
|
|
|
const dropZoneBgTopClassName = cx({
|
2019-07-10 07:11:48 +08:00
|
|
|
[styles.dropZoneBgTop]: true,
|
2019-03-01 05:39:57 +08:00
|
|
|
});
|
|
|
|
|
2019-11-26 00:38:00 +08:00
|
|
|
const dropZoneBgLeftClassName = cx({
|
|
|
|
[styles.dropZoneBgLeft]: true,
|
|
|
|
});
|
|
|
|
|
2019-03-01 05:39:57 +08:00
|
|
|
const dropZoneBgBottomClassName = cx({
|
2019-07-10 07:11:48 +08:00
|
|
|
[styles.dropZoneBgBottom]: true,
|
2019-03-01 05:39:57 +08:00
|
|
|
});
|
|
|
|
|
2019-11-26 00:38:00 +08:00
|
|
|
const dropZoneBgRightClassName = cx({
|
|
|
|
[styles.dropZoneBgRight]: true,
|
|
|
|
});
|
|
|
|
|
2020-06-20 13:46:10 +08:00
|
|
|
let sizeHeight;
|
|
|
|
let sizeWidth;
|
|
|
|
if (dragging) {
|
|
|
|
sizeWidth = optimalGrid.width;
|
|
|
|
sizeHeight = optimalGrid.height;
|
|
|
|
} else if (resizing) {
|
|
|
|
sizeWidth = webcamsAreaResizable.width;
|
|
|
|
sizeHeight = webcamsAreaResizable.height;
|
|
|
|
} else {
|
|
|
|
sizeWidth = webcamsAreaSize.width;
|
|
|
|
sizeHeight = webcamsAreaSize.height;
|
|
|
|
}
|
|
|
|
|
2019-03-01 05:39:57 +08:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<div
|
|
|
|
className={dropZoneTopClassName}
|
2019-11-26 00:38:00 +08:00
|
|
|
style={{ height: '15vh' }}
|
2019-07-10 07:11:48 +08:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={dropZoneBgTopClassName}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-11-26 00:38:00 +08:00
|
|
|
<div
|
|
|
|
className={dropZoneLeftClassName}
|
|
|
|
style={{
|
|
|
|
width: '15vh',
|
|
|
|
height: `calc(${mediaHeight}px - (15vh * 2))`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={dropZoneBgLeftClassName}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-03-01 05:39:57 +08:00
|
|
|
<Draggable
|
|
|
|
handle="video"
|
2019-03-05 01:29:40 +08:00
|
|
|
bounds="#container"
|
2019-03-01 05:39:57 +08:00
|
|
|
onStart={this.handleWebcamDragStart}
|
|
|
|
onStop={this.handleWebcamDragStop}
|
2019-04-12 00:35:23 +08:00
|
|
|
onMouseDown={e => e.preventDefault()}
|
2020-04-23 22:07:44 +08:00
|
|
|
disabled={swapLayout || isCameraFullscreen || BROWSER_ISMOBILE || resizing}
|
2019-07-10 07:11:48 +08:00
|
|
|
position={position}
|
2019-03-01 05:39:57 +08:00
|
|
|
>
|
2019-07-30 03:42:11 +08:00
|
|
|
<Resizable
|
2020-06-05 07:01:17 +08:00
|
|
|
minWidth={mediaWidth * WEBCAMSAREA_MIN_PERCENT}
|
|
|
|
minHeight={mediaHeight * WEBCAMSAREA_MIN_PERCENT}
|
|
|
|
maxWidth={
|
|
|
|
webcamsPlacement === 'left' || webcamsPlacement === 'right'
|
|
|
|
? mediaWidth - PRESENTATIONAREA_MIN_WIDTH
|
|
|
|
: undefined
|
|
|
|
}
|
2019-09-18 02:25:28 +08:00
|
|
|
size={
|
2019-12-06 02:01:23 +08:00
|
|
|
{
|
2020-06-20 13:46:10 +08:00
|
|
|
width: sizeWidth,
|
|
|
|
height: sizeHeight,
|
2019-12-06 02:01:23 +08:00
|
|
|
}
|
2019-09-18 02:25:28 +08:00
|
|
|
}
|
2020-06-16 19:54:52 +08:00
|
|
|
// lockAspectRatio
|
2019-09-18 02:25:28 +08:00
|
|
|
handleWrapperClass="resizeWrapper"
|
2019-12-11 05:43:22 +08:00
|
|
|
onResizeStart={this.onResizeStart}
|
2020-06-20 13:46:10 +08:00
|
|
|
onResize={(e, direction, ref, d) => {
|
2020-06-16 23:20:24 +08:00
|
|
|
this.onResizeHandle(d.width, d.height);
|
2020-06-20 13:46:10 +08:00
|
|
|
}}
|
2020-04-23 22:07:44 +08:00
|
|
|
onResizeStop={(e, direction, ref, d) => {
|
|
|
|
this.onResizeStop(d.width, d.height);
|
|
|
|
}}
|
2019-07-30 03:42:11 +08:00
|
|
|
enable={{
|
2020-04-23 22:07:44 +08:00
|
|
|
top: (webcamsPlacement === 'bottom') && !swapLayout,
|
|
|
|
bottom: (webcamsPlacement === 'top') && !swapLayout,
|
|
|
|
left: (webcamsPlacement === 'right') && !swapLayout,
|
|
|
|
right: (webcamsPlacement === 'left') && !swapLayout,
|
2019-09-18 02:25:28 +08:00
|
|
|
topLeft: false,
|
|
|
|
topRight: false,
|
|
|
|
bottomLeft: false,
|
|
|
|
bottomRight: false,
|
2019-07-30 03:42:11 +08:00
|
|
|
}}
|
|
|
|
className={
|
|
|
|
!swapLayout
|
|
|
|
? overlayClassName
|
2020-07-16 00:44:59 +08:00
|
|
|
: contentClassName}
|
2019-06-25 23:40:57 +08:00
|
|
|
style={{
|
2019-12-06 02:01:23 +08:00
|
|
|
marginLeft: 0,
|
|
|
|
marginRight: 0,
|
2019-06-25 23:40:57 +08:00
|
|
|
}}
|
2019-03-01 05:39:57 +08:00
|
|
|
>
|
2019-07-30 03:42:11 +08:00
|
|
|
{
|
|
|
|
!disableVideo
|
|
|
|
&& !audioModalIsOpen
|
|
|
|
? (
|
|
|
|
<VideoProviderContainer
|
|
|
|
swapLayout={swapLayout}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
</Resizable>
|
2019-03-01 05:39:57 +08:00
|
|
|
</Draggable>
|
|
|
|
<div
|
|
|
|
className={dropZoneBottomClassName}
|
2019-11-26 00:38:00 +08:00
|
|
|
style={{ height: '15vh' }}
|
2019-07-10 07:11:48 +08:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={dropZoneBgBottomClassName}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-11-26 00:38:00 +08:00
|
|
|
<div
|
|
|
|
className={dropZoneRightClassName}
|
|
|
|
style={{
|
|
|
|
width: '15vh',
|
|
|
|
height: `calc(${mediaHeight}px - (15vh * 2))`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={dropZoneBgRightClassName}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-03-01 05:39:57 +08:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-24 06:24:31 +08:00
|
|
|
WebcamDraggable.propTypes = propTypes;
|
|
|
|
WebcamDraggable.defaultProps = defaultProps;
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
export default withDraggableConsumer(withLayoutConsumer(WebcamDraggable));
|