Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Feb 23, 2018
1 parent 3a4f9a1 commit d28e51d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/ui/handler/drag_pan.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class DragPanHandler {
if (this._map.dragRotate.isActive()) return;
if (this.isActive()) return;

// Bind window-level event listeners for move and up/end events. In the absence of
// the pointer capture API, which is not supported by all necessary platforms,
// window-level event listeners give us the best shot at capturing events that
// fall outside the map canvas element. Use `{capture: true}` for the move event
// to prevent map move events from being fired during a drag.
if (e.touches) {
if ((e.touches: any).length > 1) return;
window.document.addEventListener('touchmove', this._onMove, {capture: true});
Expand All @@ -101,8 +106,8 @@ class DragPanHandler {
window.document.addEventListener('mouseup', this._onUp);
}

// Deactivate DragPan when the window loses focus. Otherwise if a mouseup occurs when the window
// isn't in focus, DragPan will still be active even though the mouse is no longer pressed.
// Deactivate when the window loses focus. Otherwise if a mouseup occurs when the window
// isn't in focus, dragging will continue even though the mouse is no longer pressed.
window.addEventListener('blur', this._onUp);

this._active = false;
Expand Down
9 changes: 8 additions & 1 deletion src/ui/handler/drag_rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ class DragRotateHandler {

DOM.disableDrag();

// Bind window-level event listeners for move and up/end events. In the absence of
// the pointer capture API, which is not supported by all necessary platforms,
// window-level event listeners give us the best shot at capturing events that
// fall outside the map canvas element. Use `{capture: true}` for the move event
// to prevent map move events from being fired during a drag.
window.document.addEventListener('mousemove', this._onMove, {capture: true});
window.document.addEventListener('mouseup', this._onUp);
/* Deactivate DragRotate when the window looses focus. Otherwise if a mouseup occurs when the window isn't in focus, DragRotate will still be active even though the mouse is no longer pressed. */

// Deactivate when the window loses focus. Otherwise if a mouseup occurs when the window
// isn't in focus, dragging will continue even though the mouse is no longer pressed.
window.addEventListener('blur', this._onUp);

this._active = false;
Expand Down

0 comments on commit d28e51d

Please sign in to comment.