Skip to content

Commit

Permalink
de-activate DragPan when window loosese focus
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewharvey committed Mar 9, 2017
1 parent 39c04a4 commit ce88d07
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ui/handler/drag_pan.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class DragPanHandler {
window.document.addEventListener('mousemove', this._onMove);
window.document.addEventListener('mouseup', this._onMouseUp);
}
window.addEventListener('blur', this._onMouseUp);

this._active = false;
this._startPos = this._pos = DOM.mousePos(this._el, e);
Expand Down Expand Up @@ -169,6 +170,7 @@ class DragPanHandler {
this._onUp(e);
window.document.removeEventListener('mousemove', this._onMove);
window.document.removeEventListener('mouseup', this._onMouseUp);
window.removeEventListener('blur', this._onMouseUp);
}

_onTouchEnd(e) {
Expand All @@ -193,7 +195,7 @@ class DragPanHandler {
if (e.ctrlKey) return true;
const buttons = 1, // left button
button = 0; // left button
return (e.type === 'mousemove' ? e.buttons & buttons === 0 : e.button !== button);
return (e.type === 'mousemove' ? e.buttons & buttons === 0 : e.button && e.button !== button);
}
}

Expand Down

0 comments on commit ce88d07

Please sign in to comment.