src/viewport.js
function(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);
        this._raiseConstraintsEvent(immediately);

        if (bounds.x !== constrainedBounds.x ||
            bounds.y !== constrainedBounds.y ||
            immediately) {
            this.fitBounds(
                constrainedBounds.rotate(-this.getRotation()),
                immediately);
        }
        return this;
    }
function(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);
        this._raiseConstraintsEvent(immediately);

        if (bounds.x !== constrainedBounds.x ||
            bounds.y !== constrainedBounds.y ||
            immediately) {
            this.fitBounds(
                constrainedBounds.rotate(-this.getRotation()),
                immediately);
        }
        return this;
    }
function ( 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 ) ; this . _raiseConstraintsEvent ( immediately ) ; if ( bounds . x !== constrainedBounds . x || bounds . y !== constrainedBounds . y || immediately ) { this . fitBounds ( constrainedBounds . rotate ( - this . getRotation ( ) ) , immediately ) ; } return this ; }
Enforces the minZoom, maxZoom and visibilityRatio constraints by
zooming and panning to the closest acceptable zoom and location.
@function
@param {Boolean} [immediately=false]
@return {OpenSeadragon.Viewport} Chainable.
@fires OpenSeadragon.Viewer.event:constrain
Enforces the minZoom maxZoom and visibilityRatio constraints by zooming and panning to the closest acceptable zoom and location .