Skip to content

Commit

Permalink
start drag only with main mouse button
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlk committed Dec 1, 2019
1 parent f6273ff commit 4fa2ecd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Rect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const zoomableMap = {
'sw': 'bl'
}

const MAIN_BUTTON = 0;

export default class Rect extends PureComponent {
static propTypes = {
styles: PropTypes.object,
Expand All @@ -35,6 +37,7 @@ export default class Rect extends PureComponent {

// Drag
startDrag = (e) => {
if (e.button !== MAIN_BUTTON) return
let { clientX: startX, clientY: startY } = e
this.props.onDragStart && this.props.onDragStart()
this._isMouseDown = true
Expand All @@ -61,7 +64,7 @@ export default class Rect extends PureComponent {

// Rotate
startRotate = (e) => {
if (e.button !== 0) return
if (e.button !== MAIN_BUTTON) return
const { clientX, clientY } = e
const { styles: { transform: { rotateAngle: startAngle } } } = this.props
const rect = this.$element.getBoundingClientRect()
Expand Down Expand Up @@ -99,7 +102,7 @@ export default class Rect extends PureComponent {

// Resize
startResize = (e, cursor) => {
if (e.button !== 0) return
if (e.button !== MAIN_BUTTON) return
document.body.style.cursor = cursor
const { styles: { position: { centerX, centerY }, size: { width, height }, transform: { rotateAngle } } } = this.props
const { clientX: startX, clientY: startY } = e
Expand Down

0 comments on commit 4fa2ecd

Please sign in to comment.