mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-23 05:36:09 +03:00
Viewport.zoomTo and zoomBy now respect ref point even when immediately = true
This commit is contained in:
parent
458bbd61b6
commit
de9fa90fac
@ -765,7 +765,9 @@ $.Viewport.prototype = {
|
||||
null;
|
||||
|
||||
if ( immediately ) {
|
||||
this.zoomSpring.resetTo( zoom );
|
||||
this._updateZoom({
|
||||
resetTo: zoom
|
||||
});
|
||||
} else {
|
||||
this.zoomSpring.springTo( zoom );
|
||||
}
|
||||
@ -891,27 +893,7 @@ $.Viewport.prototype = {
|
||||
* @function
|
||||
*/
|
||||
update: function() {
|
||||
var oldZoomPixel,
|
||||
newZoomPixel,
|
||||
deltaZoomPixels,
|
||||
deltaZoomPoints;
|
||||
|
||||
if (this.zoomPoint) {
|
||||
oldZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
||||
}
|
||||
|
||||
this.zoomSpring.update();
|
||||
|
||||
if (this.zoomPoint && this.zoomSpring.current.value != this._oldZoom) {
|
||||
newZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
||||
deltaZoomPixels = newZoomPixel.minus( oldZoomPixel );
|
||||
deltaZoomPoints = this.deltaPointsFromPixels( deltaZoomPixels, true );
|
||||
|
||||
this.centerSpringX.shiftBy( deltaZoomPoints.x );
|
||||
this.centerSpringY.shiftBy( deltaZoomPoints.y );
|
||||
} else {
|
||||
this.zoomPoint = null;
|
||||
}
|
||||
this._updateZoom();
|
||||
|
||||
this.centerSpringX.update();
|
||||
this.centerSpringY.update();
|
||||
@ -927,6 +909,35 @@ $.Viewport.prototype = {
|
||||
return changed;
|
||||
},
|
||||
|
||||
// private
|
||||
_updateZoom: function(options) {
|
||||
var oldZoomPixel,
|
||||
newZoomPixel,
|
||||
deltaZoomPixels,
|
||||
deltaZoomPoints;
|
||||
|
||||
if (this.zoomPoint) {
|
||||
oldZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
||||
}
|
||||
|
||||
if (options && options.resetTo) {
|
||||
this.zoomSpring.resetTo(options.resetTo);
|
||||
} else {
|
||||
this.zoomSpring.update();
|
||||
}
|
||||
|
||||
if (this.zoomPoint && this.zoomSpring.current.value != this._oldZoom) {
|
||||
newZoomPixel = this.pixelFromPoint( this.zoomPoint, true );
|
||||
deltaZoomPixels = newZoomPixel.minus( oldZoomPixel );
|
||||
deltaZoomPoints = this.deltaPointsFromPixels( deltaZoomPixels, true );
|
||||
|
||||
this.centerSpringX.shiftBy( deltaZoomPoints.x );
|
||||
this.centerSpringY.shiftBy( deltaZoomPoints.y );
|
||||
} else {
|
||||
this.zoomPoint = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert a delta (translation vector) from viewport coordinates to pixels
|
||||
* coordinates. This method does not take rotation into account.
|
||||
|
Loading…
Reference in New Issue
Block a user