Fix selection cursor getting stuck on selection remove
This commit is contained in:
parent
f989ae0435
commit
c93242b884
@ -146,35 +146,36 @@ function Selection({
|
|||||||
|
|
||||||
// Update cursor when mouse enter and out of selection
|
// Update cursor when mouse enter and out of selection
|
||||||
function handleMouseEnter(event: Konva.KonvaEventObject<MouseEvent>) {
|
function handleMouseEnter(event: Konva.KonvaEventObject<MouseEvent>) {
|
||||||
let style = event.target.getStage()?.content?.style;
|
let stage = event.target.getStage();
|
||||||
if (style && hasItems) {
|
if (stage && hasItems) {
|
||||||
style.cursor = "move";
|
stage.content.style.cursor = "move";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseOut(event: Konva.KonvaEventObject<MouseEvent>) {
|
function handleMouseOut(event: Konva.KonvaEventObject<MouseEvent>) {
|
||||||
let style = event.target.getStage()?.content?.style;
|
let stage = event.target.getStage();
|
||||||
if (style) {
|
if (stage) {
|
||||||
style.cursor = "";
|
stage.content.style.cursor = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update cursor to move when selection is made
|
// Update cursor to move when selection is made or removed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasItems) {
|
var node: Konva.Node | null = null;
|
||||||
var node: Konva.Node | null = null;
|
if (lineRef.current) {
|
||||||
if (lineRef.current) {
|
node = lineRef.current;
|
||||||
node = lineRef.current;
|
} else if (rectRef.current) {
|
||||||
} else if (rectRef.current) {
|
node = rectRef.current;
|
||||||
node = rectRef.current;
|
|
||||||
}
|
|
||||||
if (node) {
|
|
||||||
let style = node.getStage()?.content?.style;
|
|
||||||
if (style) {
|
|
||||||
style.cursor = "move";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
let stage = node?.getStage();
|
||||||
|
if (stage && hasItems) {
|
||||||
|
stage.content.style.cursor = "move";
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
if (stage) {
|
||||||
|
stage.content.style.cursor = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [hasItems]);
|
}, [hasItems]);
|
||||||
|
|
||||||
const requestRef = useRef<number>();
|
const requestRef = useRef<number>();
|
||||||
|
Loading…
Reference in New Issue
Block a user