Skip to content

Commit

Permalink
fix thrown exception with certain calls to flyTo (#4761)
Browse files Browse the repository at this point in the history
  • Loading branch information
mollymerp authored May 29, 2017
1 parent f482f18 commit cb34199
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 @@ -758,7 +758,7 @@ class Camera extends Evented {
S = (r(1) - r0) / rho;

// When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
if (Math.abs(u1) < 0.000001) {
if (Math.abs(u1) < 0.000001 || isNaN(S)) {
// Perform a more or less instantaneous transition if the path is too short.
if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);

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 @@ -784,6 +784,13 @@ test('camera', (t) => {
t.end();
});

t.test('does not throw when cameras current zoom is sufficiently greater than passed zoom option', (t)=>{
const camera = createCamera({zoom: 22, center:[0, 0]});
t.doesNotThrow(()=>camera.flyTo({zoom:10, center:[0, 0]}));
t.end();

});

t.test('zooms to specified level', (t) => {
const camera = createCamera();
camera.flyTo({ zoom: 3.2, animate: false });
Expand Down

0 comments on commit cb34199

Please sign in to comment.