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;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseDown = (evt: MouseEvent<HTMLCanvasElement>) => {
|
const handleMouseDown = useCallback(
|
||||||
|
(evt: MouseEvent<HTMLCanvasElement>) => {
|
||||||
if (mode != Mode.Normal) {
|
if (mode != Mode.Normal) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -197,9 +198,12 @@ export const HudCanvas: React.FC<Props> = ({
|
||||||
moveOffsetX.current = x;
|
moveOffsetX.current = x;
|
||||||
setNewSelection({ start: x, end: x });
|
setNewSelection({ start: x, end: x });
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
[mode, selection]
|
||||||
|
);
|
||||||
|
|
||||||
const handleMouseMove = (evt: MouseEvent<HTMLCanvasElement>) => {
|
const handleMouseMove = useCallback(
|
||||||
|
(evt: MouseEvent<HTMLCanvasElement>) => {
|
||||||
const x = getCanvasX(evt);
|
const x = getCanvasX(evt);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
@ -267,9 +271,11 @@ export const HudCanvas: React.FC<Props> = ({
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
[mode, selection]
|
||||||
|
);
|
||||||
|
|
||||||
const handleMouseUp = () => {
|
const handleMouseUp = useCallback(() => {
|
||||||
if (mode == Mode.Normal) {
|
if (mode == Mode.Normal) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +289,7 @@ export const HudCanvas: React.FC<Props> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectionChange({ ...newSelection });
|
onSelectionChange({ ...newSelection });
|
||||||
};
|
}, [mode, newSelection]);
|
||||||
|
|
||||||
const handleEmptySelectionAction = useCallback(() => {
|
const handleEmptySelectionAction = useCallback(() => {
|
||||||
switch (emptySelectionAction) {
|
switch (emptySelectionAction) {
|
||||||
|
|
Loading…
Reference in New Issue