mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Fix Viewport.update with zoomPoint.
This commit is contained in:
parent
766e2b0e1f
commit
79977b09a0
@ -234,6 +234,15 @@ $.Spring.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
this.current.value = currentValue;
|
this.current.value = currentValue;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the spring is at the target value
|
||||||
|
* @function
|
||||||
|
* @returns {Boolean} True if at target value, false otherwise
|
||||||
|
*/
|
||||||
|
isAtTargetValue: function() {
|
||||||
|
return this.current.value === this.target.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -888,37 +888,37 @@ $.Viewport.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Update the zoom and center (X and Y) springs.
|
||||||
* @function
|
* @function
|
||||||
|
* @returns {Boolean} True if any change has been made, false otherwise.
|
||||||
*/
|
*/
|
||||||
update: function() {
|
update: function() {
|
||||||
var oldZoomPixel,
|
|
||||||
newZoomPixel,
|
|
||||||
deltaZoomPixels,
|
|
||||||
deltaZoomPoints;
|
|
||||||
|
|
||||||
if (this.zoomPoint) {
|
if (this.zoomPoint) {
|
||||||
oldZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
var oldZoomPixel = this.pixelFromPoint(this.zoomPoint, true);
|
||||||
}
|
this.zoomSpring.update();
|
||||||
|
var newZoomPixel = this.pixelFromPoint(this.zoomPoint, true);
|
||||||
|
|
||||||
this.zoomSpring.update();
|
var deltaZoomPixels = newZoomPixel.minus(oldZoomPixel);
|
||||||
|
var deltaZoomPoints = this.deltaPointsFromPixels(
|
||||||
|
deltaZoomPixels, true);
|
||||||
|
|
||||||
if (this.zoomPoint && this.zoomSpring.current.value != this._oldZoom) {
|
this.centerSpringX.shiftBy(deltaZoomPoints.x);
|
||||||
newZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
this.centerSpringY.shiftBy(deltaZoomPoints.y);
|
||||||
deltaZoomPixels = newZoomPixel.minus( oldZoomPixel );
|
|
||||||
deltaZoomPoints = this.deltaPointsFromPixels( deltaZoomPixels, true );
|
|
||||||
|
|
||||||
this.centerSpringX.shiftBy( deltaZoomPoints.x );
|
if (this.zoomSpring.isAtTargetValue()) {
|
||||||
this.centerSpringY.shiftBy( deltaZoomPoints.y );
|
this.zoomPoint = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.zoomPoint = null;
|
this.zoomSpring.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.centerSpringX.update();
|
this.centerSpringX.update();
|
||||||
this.centerSpringY.update();
|
this.centerSpringY.update();
|
||||||
|
|
||||||
var changed = this.centerSpringX.current.value != this._oldCenterX ||
|
var changed = this.centerSpringX.current.value !== this._oldCenterX ||
|
||||||
this.centerSpringY.current.value != this._oldCenterY ||
|
this.centerSpringY.current.value !== this._oldCenterY ||
|
||||||
this.zoomSpring.current.value != this._oldZoom;
|
this.zoomSpring.current.value !== this._oldZoom;
|
||||||
|
|
||||||
this._oldCenterX = this.centerSpringX.current.value;
|
this._oldCenterX = this.centerSpringX.current.value;
|
||||||
this._oldCenterY = this.centerSpringY.current.value;
|
this._oldCenterY = this.centerSpringY.current.value;
|
||||||
|
Loading…
Reference in New Issue
Block a user