Skip to content

Commit

Permalink
Prevent division by zero in FlyTo when currentCenter == targetCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSanchez committed Jul 30, 2015
1 parent 5a29499 commit 3c6cfaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/map/anim/Map.FlyTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ L.Map.include({
rho2 = rho * rho;

function r(i) {
var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1) / (2 * (i ? w1 : w0) * rho2);
return Math.log(Math.sqrt(b * b + 1) - b);
}

Expand All @@ -51,7 +51,7 @@ L.Map.include({
this._flyToFrame = L.Util.requestAnimFrame(frame, this);

this._move(
this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom),
this.unproject(u1 ? from.add(to.subtract(from).multiplyBy(u(s) / u1)) : from, startZoom),
this.getScaleZoom(w0 / w(s), startZoom));

} else {
Expand Down

0 comments on commit 3c6cfaa

Please sign in to comment.