Skip to content

Commit a3ecc6d

Browse files
authored
Merge pull request #11 from Visual-Regression-Tracker/34-cursor
mouse events are added
2 parents 9a8c727 + 6492761 commit a3ecc6d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/components/DrawArea.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,21 @@ const DrawArea: FunctionComponent<IDrawArea> = ({
8585
}}
8686
>
8787
<Layer>
88-
<Image image={image} />
88+
<Image
89+
image={image}
90+
onMouseOver={(event) => {
91+
document.body.style.cursor = "grab";
92+
}}
93+
onMouseDown={(event) => {
94+
document.body.style.cursor = "grabbing";
95+
}}
96+
onMouseUp={(event) => {
97+
document.body.style.cursor = "grab";
98+
}}
99+
onMouseLeave={(event) => {
100+
document.body.style.cursor = "default";
101+
}}
102+
/>
89103
{ignoreAreas.map((rect, i) => {
90104
return (
91105
<Rectangle

src/components/Rectangle.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ const Rectangle = ({ shapeProps, isSelected, onSelect, onChange }) => {
6363
height: Math.max(node.height() * scaleY),
6464
});
6565
}}
66+
onMouseOver={(event) => {
67+
document.body.style.cursor = "pointer";
68+
}}
69+
onMouseDown={(event) => {
70+
document.body.style.cursor = "grabbing";
71+
}}
72+
onMouseUp={(event) => {
73+
document.body.style.cursor = "grab";
74+
}}
75+
onMouseLeave={(event) => {
76+
document.body.style.cursor = "default";
77+
}}
6678
/>
6779
{isSelected && (
6880
<Transformer

0 commit comments

Comments
 (0)