apply only zoom constraint by default for scroll events

This commit is contained in:
Joe DF 2022-05-12 15:31:51 -04:00
parent 165aaebd4c
commit a6d1472134
2 changed files with 20 additions and 1 deletions

View File

@ -3371,7 +3371,7 @@ function onCanvasScroll( event ) {
factor,
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
);
this.viewport.applyConstraints();
this.viewport.applyZoomConstraints();
}
}

View File

@ -591,6 +591,25 @@ $.Viewport.prototype = {
return this;
},
/**
* Enforces the minZoom, maxZoom constraints by zooming to the closest acceptable zoom.
* @function
* @param {Boolean} [immediately=false]
* @return {OpenSeadragon.Viewport} Chainable.
* @fires OpenSeadragon.Viewer.event:constrain
*/
applyZoomConstraints: function(immediately) {
var actualZoom = this.getZoom();
var constrainedZoom = this._applyZoomConstraints(actualZoom);
if (actualZoom !== constrainedZoom) {
this.zoomTo(constrainedZoom, this.zoomPoint, immediately);
}
this._raiseConstraintsEvent(immediately);
return this;
},
/**
* Equivalent to {@link OpenSeadragon.Viewport#applyConstraints}
* @function