HudCanvas: add useCallbacks
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5e27c3db9a
commit
aabd0f3252
|
@ -174,7 +174,8 @@ export const HudCanvas: React.FC<Props> = ({
|
|||
return x;
|
||||
};
|
||||
|
||||
const handleMouseDown = (evt: MouseEvent<HTMLCanvasElement>) => {
|
||||
const handleMouseDown = useCallback(
|
||||
(evt: MouseEvent<HTMLCanvasElement>) => {
|
||||
if (mode != Mode.Normal) {
|
||||
return;
|
||||
}
|
||||
|
@ -197,9 +198,12 @@ export const HudCanvas: React.FC<Props> = ({
|
|||
moveOffsetX.current = x;
|
||||
setNewSelection({ start: x, end: x });
|
||||
}
|
||||
};
|
||||
},
|
||||
[mode, selection]
|
||||
);
|
||||
|
||||
const handleMouseMove = (evt: MouseEvent<HTMLCanvasElement>) => {
|
||||
const handleMouseMove = useCallback(
|
||||
(evt: MouseEvent<HTMLCanvasElement>) => {
|
||||
const x = getCanvasX(evt);
|
||||
|
||||
switch (mode) {
|
||||
|
@ -267,9 +271,11 @@ export const HudCanvas: React.FC<Props> = ({
|
|||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
[mode, selection]
|
||||
);
|
||||
|
||||
const handleMouseUp = () => {
|
||||
const handleMouseUp = useCallback(() => {
|
||||
if (mode == Mode.Normal) {
|
||||
return;
|
||||
}
|
||||
|
@ -283,7 +289,7 @@ export const HudCanvas: React.FC<Props> = ({
|
|||
}
|
||||
|
||||
onSelectionChange({ ...newSelection });
|
||||
};
|
||||
}, [mode, newSelection]);
|
||||
|
||||
const handleEmptySelectionAction = useCallback(() => {
|
||||
switch (emptySelectionAction) {
|
||||
|
|
Loading…
Reference in New Issue