Listen for mouseup events from window as well as target element
Pressing an holding a mouse button and then moving the mouse out of the canvas before releasing meant that onmouseup was never triggered.
This commit is contained in:
parent
8a147535de
commit
0d0f754aad
|
@ -609,10 +609,12 @@ that.grab = function() {
|
||||||
|
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
Util.addEvent(c, 'touchstart', onMouseDown);
|
Util.addEvent(c, 'touchstart', onMouseDown);
|
||||||
|
Util.addEvent(window, 'touchend', onMouseUp);
|
||||||
Util.addEvent(c, 'touchend', onMouseUp);
|
Util.addEvent(c, 'touchend', onMouseUp);
|
||||||
Util.addEvent(c, 'touchmove', onMouseMove);
|
Util.addEvent(c, 'touchmove', onMouseMove);
|
||||||
} else {
|
} else {
|
||||||
Util.addEvent(c, 'mousedown', onMouseDown);
|
Util.addEvent(c, 'mousedown', onMouseDown);
|
||||||
|
Util.addEvent(window, 'mouseup', onMouseUp);
|
||||||
Util.addEvent(c, 'mouseup', onMouseUp);
|
Util.addEvent(c, 'mouseup', onMouseUp);
|
||||||
Util.addEvent(c, 'mousemove', onMouseMove);
|
Util.addEvent(c, 'mousemove', onMouseMove);
|
||||||
Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||||
|
@ -632,10 +634,12 @@ that.ungrab = function() {
|
||||||
|
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
Util.removeEvent(c, 'touchstart', onMouseDown);
|
Util.removeEvent(c, 'touchstart', onMouseDown);
|
||||||
|
Util.removeEvent(window, 'touchend', onMouseUp);
|
||||||
Util.removeEvent(c, 'touchend', onMouseUp);
|
Util.removeEvent(c, 'touchend', onMouseUp);
|
||||||
Util.removeEvent(c, 'touchmove', onMouseMove);
|
Util.removeEvent(c, 'touchmove', onMouseMove);
|
||||||
} else {
|
} else {
|
||||||
Util.removeEvent(c, 'mousedown', onMouseDown);
|
Util.removeEvent(c, 'mousedown', onMouseDown);
|
||||||
|
Util.removeEvent(window, 'mouseup', onMouseUp);
|
||||||
Util.removeEvent(c, 'mouseup', onMouseUp);
|
Util.removeEvent(c, 'mouseup', onMouseUp);
|
||||||
Util.removeEvent(c, 'mousemove', onMouseMove);
|
Util.removeEvent(c, 'mousemove', onMouseMove);
|
||||||
Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||||
|
|
Loading…
Reference in New Issue