Restore applyConstraints to avoid panning when clicking at max zoom.

This commit is contained in:
Antoine Vandecreme 2016-05-12 18:01:18 -04:00
parent 0c398eacdb
commit 07d66ce655

View File

@ -474,6 +474,13 @@ $.Viewport.prototype = {
} }
}, },
// private
_applyZoomConstraints: function(zoom) {
return Math.max(
Math.min(zoom, this.getMaxZoom()),
this.getMinZoom());
},
/** /**
* @function * @function
* @private * @private
@ -563,7 +570,23 @@ $.Viewport.prototype = {
* @fires OpenSeadragon.Viewer.event:constrain * @fires OpenSeadragon.Viewer.event:constrain
*/ */
applyConstraints: function(immediately) { applyConstraints: function(immediately) {
this.fitBoundsWithConstraints(this.getBounds(), immediately); var actualZoom = this.getZoom();
var constrainedZoom = this._applyZoomConstraints(actualZoom);
if (actualZoom !== constrainedZoom) {
this.zoomTo(constrainedZoom, this.zoomPoint, immediately);
}
var bounds = this.getBoundsNoRotate();
var constrainedBounds = this._applyBoundaryConstraints(
bounds, immediately);
if (bounds.x !== constrainedBounds.x ||
bounds.y !== constrainedBounds.y ||
immediately) {
this.fitBounds(constrainedBounds.rotate(this.getRotation()),
immediately);
}
return this; return this;
}, },
@ -615,10 +638,7 @@ $.Viewport.prototype = {
if (constraints) { if (constraints) {
var newBoundsAspectRatio = newBounds.getAspectRatio(); var newBoundsAspectRatio = newBounds.getAspectRatio();
var newConstrainedZoom = Math.max( var newConstrainedZoom = this._applyZoomConstraints(newZoom);
Math.min(newZoom, this.getMaxZoom()),
this.getMinZoom()
);
if (newZoom !== newConstrainedZoom) { if (newZoom !== newConstrainedZoom) {
newZoom = newConstrainedZoom; newZoom = newConstrainedZoom;