From 2b9a51036fb2235db1311b3c603381c5b3b6fd7c Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 20 Jan 2015 16:09:54 -0800 Subject: [PATCH] Fixed change detection for viewport (after recent spring change) --- src/viewport.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) 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; },