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(