refactor: rever highlighter
This commit is contained in:
@@ -4,7 +4,6 @@ import { getMappedCoordinates } from "../../helpers/inputHelpers";
|
|||||||
import { useGlobalInfoStore } from "../../context/globalInfo";
|
import { useGlobalInfoStore } from "../../context/globalInfo";
|
||||||
import { GenericModal } from '../atoms/GenericModal';
|
import { GenericModal } from '../atoms/GenericModal';
|
||||||
import { Box, Button, Typography } from '@mui/material';
|
import { Box, Button, Typography } from '@mui/material';
|
||||||
import { Highlighter } from "../atoms/Highlighter"
|
|
||||||
|
|
||||||
interface CreateRefCallback {
|
interface CreateRefCallback {
|
||||||
(ref: React.RefObject<HTMLCanvasElement>): void;
|
(ref: React.RefObject<HTMLCanvasElement>): void;
|
||||||
@@ -81,8 +80,19 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
|
|||||||
break;
|
break;
|
||||||
case 'mousedown':
|
case 'mousedown':
|
||||||
if (highlighterData) {
|
if (highlighterData) {
|
||||||
setPendingClick(coordinates);
|
const highlightRect = highlighterData.rect;
|
||||||
setShowConfirmation(true);
|
if (
|
||||||
|
coordinates.x >= highlightRect.left &&
|
||||||
|
coordinates.x <= highlightRect.right &&
|
||||||
|
coordinates.y >= highlightRect.top &&
|
||||||
|
coordinates.y <= highlightRect.bottom
|
||||||
|
) {
|
||||||
|
setPendingClick(coordinates);
|
||||||
|
setShowConfirmation(true);
|
||||||
|
} else {
|
||||||
|
socket.emit('input:mousedown', coordinates);
|
||||||
|
notifyLastAction('click');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
socket.emit('input:mousedown', coordinates);
|
socket.emit('input:mousedown', coordinates);
|
||||||
notifyLastAction('click');
|
notifyLastAction('click');
|
||||||
@@ -147,21 +157,6 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<canvas
|
|
||||||
tabIndex={0}
|
|
||||||
ref={canvasRef}
|
|
||||||
height={720}
|
|
||||||
width={1280}
|
|
||||||
/>
|
|
||||||
{!showConfirmation && highlighterData && canvasRef.current && (
|
|
||||||
<Highlighter
|
|
||||||
unmodifiedRect={highlighterData.rect}
|
|
||||||
displayedSelector={highlighterData.selector}
|
|
||||||
width={width}
|
|
||||||
height={height}
|
|
||||||
canvasRect={canvasRef.current.getBoundingClientRect()}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<GenericModal
|
<GenericModal
|
||||||
isOpen={showConfirmation}
|
isOpen={showConfirmation}
|
||||||
onClose={() => setShowConfirmation(false)}
|
onClose={() => setShowConfirmation(false)}
|
||||||
@@ -173,6 +168,12 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
|
|||||||
onNo={() => handleConfirmation(false)}
|
onNo={() => handleConfirmation(false)}
|
||||||
/>
|
/>
|
||||||
</GenericModal>
|
</GenericModal>
|
||||||
|
<canvas
|
||||||
|
tabIndex={0}
|
||||||
|
ref={canvasRef}
|
||||||
|
height={720}
|
||||||
|
width={1280}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user