Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag should start only when MAIN mouse button is clicked #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_MOUSE_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_MOUSE_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_MOUSE_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_MOUSE_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