fix(camera): prevent dock position change on click

This commit is contained in:
Joao Victor 2022-05-25 14:18:37 -03:00
parent 7d7f7e88fe
commit db5a788719

View File

@ -23,6 +23,7 @@ const WebcamComponent = ({
const [isFullscreen, setIsFullScreen] = useState(false);
const [resizeStart, setResizeStart] = useState({ width: 0, height: 0 });
const [cameraMaxWidth, setCameraMaxWidth] = useState(0);
const [draggedAtLeastOneTime, setDraggedAtLeastOneTime] = useState(false);
const lastSize = Storage.getItem('webcamSize') || { width: 0, height: 0 };
const { width: lastWidth, height: lastHeight } = lastSize;
@ -140,9 +141,10 @@ const WebcamComponent = ({
const handleWebcamDragStop = (e) => {
setIsDragging(false);
setDraggedAtLeastOneTime(false);
document.body.style.overflow = 'auto';
if (Object.values(CAMERADOCK_POSITION).includes(e.target.id)) {
if (Object.values(CAMERADOCK_POSITION).includes(e.target.id) && draggedAtLeastOneTime) {
layoutContextDispatch({
type: ACTIONS.SET_CAMERA_DOCK_POSITION,
value: e.target.id,
@ -181,6 +183,11 @@ const WebcamComponent = ({
handle="video"
bounds="html"
onStart={handleWebcamDragStart}
onDrag={() => {
if (!draggedAtLeastOneTime) {
setDraggedAtLeastOneTime(true);
}
}}
onStop={handleWebcamDragStop}
onMouseDown={
cameraDock.isDraggable ? (e) => e.preventDefault() : undefined