mirror of
https://github.com/konvajs/konva.git
synced 2026-01-22 03:11:53 +08:00
Merge pull request #517 from rfrei/rfrei-fix_mouse_mobile
fix mouse events on mobile devices
This commit is contained in:
20
src/Stage.js
20
src/Stage.js
@@ -396,13 +396,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_mouseover: function(evt) {
|
_mouseover: function(evt) {
|
||||||
if (!Konva.UA.mobile) {
|
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
this._fire(CONTENT_MOUSEOVER, { evt: evt });
|
this._fire(CONTENT_MOUSEOVER, { evt: evt });
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_mouseout: function(evt) {
|
_mouseout: function(evt) {
|
||||||
if (!Konva.UA.mobile) {
|
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var targetShape = this.targetShape;
|
var targetShape = this.targetShape;
|
||||||
|
|
||||||
@@ -414,25 +411,12 @@
|
|||||||
this.pointerPos = undefined;
|
this.pointerPos = undefined;
|
||||||
|
|
||||||
this._fire(CONTENT_MOUSEOUT, { evt: evt });
|
this._fire(CONTENT_MOUSEOUT, { evt: evt });
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_mousemove: function(evt) {
|
_mousemove: function(evt) {
|
||||||
// workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event
|
// workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event
|
||||||
if (Konva.UA.ieMobile) {
|
if (Konva.UA.ieMobile) {
|
||||||
return this._touchmove(evt);
|
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);
|
this._setPointerPosition(evt);
|
||||||
var shape;
|
var shape;
|
||||||
|
|
||||||
@@ -485,7 +469,6 @@
|
|||||||
if (Konva.UA.ieMobile) {
|
if (Konva.UA.ieMobile) {
|
||||||
return this._touchstart(evt);
|
return this._touchstart(evt);
|
||||||
}
|
}
|
||||||
if (!Konva.UA.mobile) {
|
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var shape = this.getIntersection(this.getPointerPosition());
|
var shape = this.getIntersection(this.getPointerPosition());
|
||||||
|
|
||||||
@@ -504,7 +487,6 @@
|
|||||||
|
|
||||||
// content event
|
// content event
|
||||||
this._fire(CONTENT_MOUSEDOWN, { evt: evt });
|
this._fire(CONTENT_MOUSEDOWN, { evt: evt });
|
||||||
}
|
|
||||||
|
|
||||||
// always call preventDefault for desktop events because some browsers
|
// always call preventDefault for desktop events because some browsers
|
||||||
// try to drag and drop the canvas element
|
// try to drag and drop the canvas element
|
||||||
@@ -520,7 +502,6 @@
|
|||||||
if (Konva.UA.ieMobile) {
|
if (Konva.UA.ieMobile) {
|
||||||
return this._touchend(evt);
|
return this._touchend(evt);
|
||||||
}
|
}
|
||||||
if (!Konva.UA.mobile) {
|
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var shape = this.getIntersection(this.getPointerPosition()),
|
var shape = this.getIntersection(this.getPointerPosition()),
|
||||||
clickStartShape = this.clickStartShape,
|
clickStartShape = this.clickStartShape,
|
||||||
@@ -588,7 +569,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Konva.listenClickTap = false;
|
Konva.listenClickTap = false;
|
||||||
}
|
|
||||||
|
|
||||||
// always call preventDefault for desktop events because some browsers
|
// always call preventDefault for desktop events because some browsers
|
||||||
// try to drag and drop the canvas element
|
// try to drag and drop the canvas element
|
||||||
|
|||||||
Reference in New Issue
Block a user