diff --git a/src/viewport.js b/src/viewport.js index d6fc2984..d6fd8606 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -132,6 +132,10 @@ $.Viewport = function( options ) { animationTime: this.animationTime }); + this._oldCenterX = this.centerSpringX.current.value; + this._oldCenterY = this.centerSpringY.current.value; + this._oldZoom = this.zoomSpring.current.value; + if (this.contentSize) { this.resetContentSize( this.contentSize ); } else { @@ -856,10 +860,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ * @function */ update: function() { - var oldCenterX = this.centerSpringX.current.value, - oldCenterY = this.centerSpringY.current.value, - oldZoom = this.zoomSpring.current.value, - oldZoomPixel, + var oldZoomPixel, newZoomPixel, deltaZoomPixels, deltaZoomPoints; @@ -870,7 +871,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ this.zoomSpring.update(); - if (this.zoomPoint && this.zoomSpring.current.value != oldZoom) { + if (this.zoomPoint && this.zoomSpring.current.value != this._oldZoom) { newZoomPixel = this.pixelFromPoint( this.zoomPoint, true ); deltaZoomPixels = newZoomPixel.minus( oldZoomPixel ); deltaZoomPoints = this.deltaPointsFromPixels( deltaZoomPixels, true ); @@ -884,9 +885,15 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ this.centerSpringX.update(); this.centerSpringY.update(); - return this.centerSpringX.current.value != oldCenterX || - this.centerSpringY.current.value != oldCenterY || - this.zoomSpring.current.value != oldZoom; + var changed = this.centerSpringX.current.value != this._oldCenterX || + this.centerSpringY.current.value != this._oldCenterY || + this.zoomSpring.current.value != this._oldZoom; + + this._oldCenterX = this.centerSpringX.current.value; + this._oldCenterY = this.centerSpringY.current.value; + this._oldZoom = this.zoomSpring.current.value; + + return changed; },