From 2172da6aaaed78ce878977b4fbc3f28131aa65ff Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 20 Jan 2015 17:19:13 -0800 Subject: [PATCH] * Fixed an error in fitBounds that occurred sometimes with immediately = true --- changelog.txt | 1 + src/viewport.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index d3a20e31..6456733f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -46,6 +46,7 @@ OPENSEADRAGON CHANGELOG * Added ajaxWithCredentials option (#543) * Added viewport-change event for after the viewport changes but before it's drawn * A spring's current value is now updated immediately on reset (#524) +* Fixed an error in fitBounds that occurred sometimes with immediately = true 1.2.1: (in progress) diff --git a/src/viewport.js b/src/viewport.js index d6fd8606..b6b57e27 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -588,11 +588,17 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ } newBounds = this._applyBoundaryConstraints( newBounds, immediately ); + center = newBounds.getCenter(); + } + + if (immediately) { + this.panTo( center, true ); + return this.zoomTo(newZoom, null, true); } if (Math.abs(newZoom - oldZoom) < 0.00000000001 || Math.abs(newBounds.width - oldBounds.width) < 0.00000000001) { - return this.panTo( constraints ? newBounds.getCenter() : center, immediately ); + return this.panTo( center, immediately ); } referencePoint = oldBounds.getTopLeft().times(