From f14cab26bcdb764217bf03ad7e3616b17fa8a20d Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Thu, 9 Aug 2018 09:21:45 -0600 Subject: [PATCH] fix exceptions resulting from uninitialized variable in scrollZoom see: https://github.com/mapbox/mapbox-gl-js/pull/6924 Closes #6782 Closes #6486 Replaces #6921 --- src/ui/handler/scroll_zoom.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/handler/scroll_zoom.js b/src/ui/handler/scroll_zoom.js index bfee1fba2af..dcf7cda093b 100644 --- a/src/ui/handler/scroll_zoom.js +++ b/src/ui/handler/scroll_zoom.js @@ -209,11 +209,14 @@ class ScrollZoomHandler { this._delta = 0; } + const targetZoom = typeof this._targetZoom === 'number' ? this._targetZoom : tr.zoom; + const startZoom = this._startZoom; + const easing = this._easing; let finished = false; - if (this._type === 'wheel') { + if (this._type === 'wheel' && startZoom && easing) { const t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1); - const k = this._easing(t); - tr.zoom = interpolate(this._startZoom, this._targetZoom, k); + const k = easing(t); + tr.zoom = interpolate(startZoom, targetZoom, k); if (t < 1) { if (!this._frameId) { this._frameId = this._map._requestRenderFrame(this._onScrollFrame); @@ -222,7 +225,7 @@ class ScrollZoomHandler { finished = true; } } else { - tr.zoom = this._targetZoom; + tr.zoom = targetZoom; finished = true; }