code: 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;
      }
docs: 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