diff --git a/src/ui/camera.js b/src/ui/camera.js index ad4c48822af..4cba4f200fb 100644 --- a/src/ui/camera.js +++ b/src/ui/camera.js @@ -1185,7 +1185,7 @@ class Camera extends Evented { } if (!allowGestures) { const handlers = (this: any).handlers; - if (handlers) handlers.stop(); + if (handlers) handlers.stop(false); } return this; } diff --git a/src/ui/handler_manager.js b/src/ui/handler_manager.js index 608acccd2ed..56d538443c4 100644 --- a/src/ui/handler_manager.js +++ b/src/ui/handler_manager.js @@ -104,7 +104,6 @@ class HandlerManager { _updatingCamera: boolean; _changes: Array<[HandlerResult, Object, any]>; _previousActiveHandlers: { [string]: Handler }; - _bearingChanged: boolean; _listeners: Array<[HTMLElement, string, void | {passive?: boolean, capture?: boolean}]>; constructor(map: Map, options: { interactive: boolean, pitchWithRotate: boolean, clickTolerance: number, bearingSnap: number}) { @@ -235,7 +234,7 @@ class HandlerManager { this._handlersById[handlerName] = handler; } - stop() { + stop(allowEndAnimation: boolean) { // do nothing if this method was triggered by a gesture update if (this._updatingCamera) return; @@ -243,7 +242,7 @@ class HandlerManager { handler.reset(); } this._inertia.clear(); - this._fireEvents({}, {}); + this._fireEvents({}, {}, allowEndAnimation); this._changes = []; } @@ -293,7 +292,7 @@ class HandlerManager { handleEvent(e: InputEvent | RenderFrameEvent, eventName?: string) { if (e.type === 'blur') { - this.stop(); + this.stop(true); return; } @@ -358,7 +357,7 @@ class HandlerManager { const {cameraAnimation} = mergedHandlerResult; if (cameraAnimation) { this._inertia.clear(); - this._fireEvents({}, {}); + this._fireEvents({}, {}, true); this._changes = []; cameraAnimation(this._map); } @@ -416,7 +415,7 @@ class HandlerManager { const tr = map.transform; if (!hasChange(combinedResult)) { - return this._fireEvents(combinedEventsInProgress, deactivatedHandlers); + return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); } let {panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround} = combinedResult; @@ -437,11 +436,11 @@ class HandlerManager { this._map._update(); if (!combinedResult.noInertia) this._inertia.record(combinedResult); - this._fireEvents(combinedEventsInProgress, deactivatedHandlers); + this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); } - _fireEvents(newEventsInProgress: { [string]: Object }, deactivatedHandlers: Object) { + _fireEvents(newEventsInProgress: { [string]: Object }, deactivatedHandlers: Object, allowEndAnimation: boolean) { const wasMoving = isMoving(this._eventsInProgress); const nowMoving = isMoving(newEventsInProgress); @@ -465,8 +464,6 @@ class HandlerManager { this._fireEvent(name, startEvents[name]); } - if (newEventsInProgress.rotate) this._bearingChanged = true; - if (nowMoving) { this._fireEvent('move', nowMoving.originalEvent); } @@ -493,7 +490,7 @@ class HandlerManager { } const stillMoving = isMoving(this._eventsInProgress); - if ((wasMoving || nowMoving) && !stillMoving) { + if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) { this._updatingCamera = true; const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions); @@ -510,7 +507,6 @@ class HandlerManager { this._map.resetNorth(); } } - this._bearingChanged = false; this._updatingCamera = false; }