Skip to content

Commit

Permalink
fix exceptions resulting from uninitialized variable in scrollZoom
Browse files Browse the repository at this point in the history
see:
mapbox#6924

Closes mapbox#6782
Closes mapbox#6486
Replaces mapbox#6921
  • Loading branch information
pirxpilot committed Aug 9, 2018
1 parent d017743 commit f14cab2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -222,7 +225,7 @@ class ScrollZoomHandler {
finished = true;
}
} else {
tr.zoom = this._targetZoom;
tr.zoom = targetZoom;
finished = true;
}

Expand Down

0 comments on commit f14cab2

Please sign in to comment.