dist/viewer.common.js
function zoomTo(ratio) {
    var hasTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

    var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

    var _zoomable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

    var options = this.options,
        pointers = this.pointers,
        imageData = this.imageData;


    ratio = Math.max(0, ratio);

    if (isNumber(ratio) && this.viewed && !this.played && (_zoomable || options.zoomable)) {
      if (!_zoomable) {
        var minZoomRatio = Math.max(0.01, options.minZoomRatio);
        var maxZoomRatio = Math.min(100, options.maxZoomRatio);

        ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
      }

      if (_originalEvent && ratio > 0.95 && ratio < 1.05) {
        ratio = 1;
      }

      var newWidth = imageData.naturalWidth * ratio;
      var newHeight = imageData.naturalHeight * ratio;

      if (_originalEvent) {
        var offset = getOffset(this.viewer);
        var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
          pageX: _originalEvent.pageX,
          pageY: _originalEvent.pageY
        };

        // Zoom from the triggering point of the event
        imageData.left -= (newWidth - imageData.width) * ((center.pageX - offset.left - imageData.left) / imageData.width);
        imageData.top -= (newHeight - imageData.height) * ((center.pageY - offset.top - imageData.top) / imageData.height);
      } else {
        // Zoom from the center of the image
        imageData.left -= (newWidth - imageData.width) / 2;
        imageData.top -= (newHeight - imageData.height) / 2;
      }

      imageData.width = newWidth;
      imageData.height = newHeight;
      imageData.ratio = ratio;
      this.renderImage();

      if (hasTooltip) {
        this.tooltip();
      }
    }

    return this;
  }
function zoomTo(ratio) {
    var hasTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

    var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

    var _zoomable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

    var options = this.options,
        pointers = this.pointers,
        imageData = this.imageData;


    ratio = Math.max(0, ratio);

    if (isNumber(ratio) && this.viewed && !this.played && (_zoomable || options.zoomable)) {
      if (!_zoomable) {
        var minZoomRatio = Math.max(0.01, options.minZoomRatio);
        var maxZoomRatio = Math.min(100, options.maxZoomRatio);

        ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
      }

      if (_originalEvent && ratio > 0.95 && ratio < 1.05) {
        ratio = 1;
      }

      var newWidth = imageData.naturalWidth * ratio;
      var newHeight = imageData.naturalHeight * ratio;

      if (_originalEvent) {
        var offset = getOffset(this.viewer);
        var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
          pageX: _originalEvent.pageX,
          pageY: _originalEvent.pageY
        };

        // Zoom from the triggering point of the event
        imageData.left -= (newWidth - imageData.width) * ((center.pageX - offset.left - imageData.left) / imageData.width);
        imageData.top -= (newHeight - imageData.height) * ((center.pageY - offset.top - imageData.top) / imageData.height);
      } else {
        // Zoom from the center of the image
        imageData.left -= (newWidth - imageData.width) / 2;
        imageData.top -= (newHeight - imageData.height) / 2;
      }

      imageData.width = newWidth;
      imageData.height = newHeight;
      imageData.ratio = ratio;
      this.renderImage();

      if (hasTooltip) {
        this.tooltip();
      }
    }

    return this;
  }
function zoomTo ( ratio ) { var hasTooltip = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : false ; var _originalEvent = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : null ; var _zoomable = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : false ; var options = this . options , pointers = this . pointers , imageData = this . imageData ; ratio = Math . max ( 0 , ratio ) ; if ( isNumber ( ratio ) && this . viewed && ! this . played && ( _zoomable || options . zoomable ) ) { if ( ! _zoomable ) { var minZoomRatio = Math . max ( 0.01 , options . minZoomRatio ) ; var maxZoomRatio = Math . min ( 100 , options . maxZoomRatio ) ; ratio = Math . min ( Math . max ( ratio , minZoomRatio ) , maxZoomRatio ) ; } if ( _originalEvent && ratio > 0.95 && ratio < 1.05 ) { ratio = 1 ; } var newWidth = imageData . naturalWidth * ratio ; var newHeight = imageData . naturalHeight * ratio ; if ( _originalEvent ) { var offset = getOffset ( this . viewer ) ; var center = pointers && Object . keys ( pointers ) . length ? getPointersCenter ( pointers ) : { pageX : _originalEvent . pageX , pageY : _originalEvent . pageY } ; // Zoom from the triggering point of the event imageData . left -= ( newWidth - imageData . width ) * ( ( center . pageX - offset . left - imageData . left ) / imageData . width ) ; imageData . top -= ( newHeight - imageData . height ) * ( ( center . pageY - offset . top - imageData . top ) / imageData . height ) ; } else { // Zoom from the center of the image imageData . left -= ( newWidth - imageData . width ) / 2 ; imageData . top -= ( newHeight - imageData . height ) / 2 ; } imageData . width = newWidth ; imageData . height = newHeight ; imageData . ratio = ratio ; this . renderImage ( ) ; if ( hasTooltip ) { this . tooltip ( ) ; } } return this ; }
Zoom the image to an absolute ratio.
@param {number} ratio - The target ratio.
@param {boolean} [hasTooltip=false] - Indicates if it has a tooltip or not.
@param {Event} [_originalEvent=null] - The original event if any.
@param {Event} [_zoomable=false] - Indicates if the current zoom is available or not.
@returns {Viewer} this
Zoom the image to an absolute ratio .