Skip to content

Commit

Permalink
fix flyTo not zooming to exact given zoom (mapbox#6828)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored and pirxpilot committed Jun 16, 2019
1 parent 9904cd2 commit a152d07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ class Camera extends Evented {
// s: The distance traveled along the flight path, measured in ρ-screenfuls.
const s = k * S;
const scale = 1 / w(s);
tr.zoom = startZoom + tr.scaleZoom(scale);
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale);

if (this._rotating) {
tr.bearing = interpolate(startBearing, bearing, k);
Expand Down
7 changes: 7 additions & 0 deletions test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,13 @@ test('camera', (t) => {
t.end();
});

t.test('zooms to integer level without floating point errors', (t) => {
const camera = createCamera({zoom: 0.6});
camera.flyTo({ zoom: 2, animate: false });
t.equal(camera.getZoom(), 2);
t.end();
});

t.test('rotates to specified bearing', (t) => {
const camera = createCamera();
camera.flyTo({ bearing: 90, animate: false });
Expand Down

0 comments on commit a152d07

Please sign in to comment.