Skip to content

Commit 5f481e9

Browse files
committed
start drag only with main mouse button
1 parent f6273ff commit 5f481e9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Rect/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const zoomableMap = {
1414
'sw': 'bl'
1515
}
1616

17+
const MAIN_MOUSE_BUTTON = 0
18+
1719
export default class Rect extends PureComponent {
1820
static propTypes = {
1921
styles: PropTypes.object,
@@ -35,6 +37,7 @@ export default class Rect extends PureComponent {
3537

3638
// Drag
3739
startDrag = (e) => {
40+
if (e.button !== MAIN_MOUSE_BUTTON) return
3841
let { clientX: startX, clientY: startY } = e
3942
this.props.onDragStart && this.props.onDragStart()
4043
this._isMouseDown = true
@@ -61,7 +64,7 @@ export default class Rect extends PureComponent {
6164

6265
// Rotate
6366
startRotate = (e) => {
64-
if (e.button !== 0) return
67+
if (e.button !== MAIN_MOUSE_BUTTON) return
6568
const { clientX, clientY } = e
6669
const { styles: { transform: { rotateAngle: startAngle } } } = this.props
6770
const rect = this.$element.getBoundingClientRect()
@@ -99,7 +102,7 @@ export default class Rect extends PureComponent {
99102

100103
// Resize
101104
startResize = (e, cursor) => {
102-
if (e.button !== 0) return
105+
if (e.button !== MAIN_MOUSE_BUTTON) return
103106
document.body.style.cursor = cursor
104107
const { styles: { position: { centerX, centerY }, size: { width, height }, transform: { rotateAngle } } } = this.props
105108
const { clientX: startX, clientY: startY } = e

0 commit comments

Comments
 (0)