@@ -14,6 +14,8 @@ const zoomableMap = {
14
14
'sw' : 'bl'
15
15
}
16
16
17
+ const MAIN_MOUSE_BUTTON = 0
18
+
17
19
export default class Rect extends PureComponent {
18
20
static propTypes = {
19
21
styles : PropTypes . object ,
@@ -35,6 +37,7 @@ export default class Rect extends PureComponent {
35
37
36
38
// Drag
37
39
startDrag = ( e ) => {
40
+ if ( e . button !== MAIN_MOUSE_BUTTON ) return
38
41
let { clientX : startX , clientY : startY } = e
39
42
this . props . onDragStart && this . props . onDragStart ( )
40
43
this . _isMouseDown = true
@@ -61,7 +64,7 @@ export default class Rect extends PureComponent {
61
64
62
65
// Rotate
63
66
startRotate = ( e ) => {
64
- if ( e . button !== 0 ) return
67
+ if ( e . button !== MAIN_MOUSE_BUTTON ) return
65
68
const { clientX, clientY } = e
66
69
const { styles : { transform : { rotateAngle : startAngle } } } = this . props
67
70
const rect = this . $element . getBoundingClientRect ( )
@@ -99,7 +102,7 @@ export default class Rect extends PureComponent {
99
102
100
103
// Resize
101
104
startResize = ( e , cursor ) => {
102
- if ( e . button !== 0 ) return
105
+ if ( e . button !== MAIN_MOUSE_BUTTON ) return
103
106
document . body . style . cursor = cursor
104
107
const { styles : { position : { centerX, centerY } , size : { width, height } , transform : { rotateAngle } } } = this . props
105
108
const { clientX : startX , clientY : startY } = e
0 commit comments