-
Notifications
You must be signed in to change notification settings - Fork 3
/
RotateHandle.jsx
58 lines (55 loc) · 1.36 KB
/
RotateHandle.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as React from "react";
import { Box } from "@mui/material";
import PropTypes from "prop-types";
/**
* Rotation handle for rotating a rectangle.
*/
export default function RotateHandle({ onRotate }) {
return (
<Box
sx={{
cursor: "default",
height: "22px",
left: "calc(50% - 5px)",
position: "absolute",
top: "-22px ",
width: "10px"
}}
onMouseDown={e => e.stopPropagation()}
onDragStart={e => e.preventDefault()}
onClick={e => e.stopPropagation()}
>
<Box
sx={theme => ({
background: theme.palette.primary.main,
height: "100%",
left: "50%",
position: "absolute",
width: "1px"
})}
></Box>
<Box
sx={theme => ({
background: theme.palette.primary.main,
borderRadius: "50%",
cursor: "grab",
height: "10px",
left: "0px",
outline: `2px solid ${theme.palette.background.paper}`,
position: "absolute",
top: "0px",
width: "10px"
})}
onMouseDown={onRotate}
onDragStart={e => e.preventDefault()}
onDrag={e => e.preventDefault()}
></Box>
</Box>
);
}
RotateHandle.propTypes = {
/**
* Callback for when the user starts rotating the rectangle
*/
onRotate: PropTypes.func
};