fix mouse events on mobile devices

- remove check for mobile flag in mouse event handlers
- remove workaround fake mousemove event in chrome browser https://code.google.com/p/chromium/issues/detail?id=161464 because it prevents mouse events working on Android mobile devices
This commit is contained in:
Technik Radio F.R.E.I 2018-12-16 00:03:03 +01:00 committed by GitHub
parent e1853e6e8b
commit 5bbb42d8fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -396,13 +396,10 @@
}
},
_mouseover: function(evt) {
if (!Konva.UA.mobile) {
this._setPointerPosition(evt);
this._fire(CONTENT_MOUSEOVER, { evt: evt });
}
},
_mouseout: function(evt) {
if (!Konva.UA.mobile) {
this._setPointerPosition(evt);
var targetShape = this.targetShape;
@ -414,25 +411,12 @@
this.pointerPos = undefined;
this._fire(CONTENT_MOUSEOUT, { evt: evt });
}
},
_mousemove: function(evt) {
// workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event
if (Konva.UA.ieMobile) {
return this._touchmove(evt);
}
// workaround fake mousemove event in chrome browser https://code.google.com/p/chromium/issues/detail?id=161464
if (
(typeof evt.movementX !== 'undefined' ||
typeof evt.movementY !== 'undefined') &&
evt.movementY === 0 &&
evt.movementX === 0
) {
return null;
}
if (Konva.UA.mobile) {
return null;
}
this._setPointerPosition(evt);
var shape;
@ -485,7 +469,6 @@
if (Konva.UA.ieMobile) {
return this._touchstart(evt);
}
if (!Konva.UA.mobile) {
this._setPointerPosition(evt);
var shape = this.getIntersection(this.getPointerPosition());
@ -504,7 +487,6 @@
// content event
this._fire(CONTENT_MOUSEDOWN, { evt: evt });
}
// always call preventDefault for desktop events because some browsers
// try to drag and drop the canvas element
@ -520,7 +502,6 @@
if (Konva.UA.ieMobile) {
return this._touchend(evt);
}
if (!Konva.UA.mobile) {
this._setPointerPosition(evt);
var shape = this.getIntersection(this.getPointerPosition()),
clickStartShape = this.clickStartShape,
@ -588,7 +569,6 @@
}
Konva.listenClickTap = false;
}
// always call preventDefault for desktop events because some browsers
// try to drag and drop the canvas element