dist/cropper.common.js
function getAdjustedSizes(_ref4) // or 'cover'
{
  var aspectRatio = _ref4.aspectRatio,
      height = _ref4.height,
      width = _ref4.width;
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain';

  var isValidNumber = function isValidNumber(value) {
    return isFinite(value) && value > 0;
  };

  if (isValidNumber(width) && isValidNumber(height)) {
    var adjustedWidth = height * aspectRatio;

    if (type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width) {
      height = width / aspectRatio;
    } else {
      width = height * aspectRatio;
    }
  } else if (isValidNumber(width)) {
    height = width / aspectRatio;
  } else if (isValidNumber(height)) {
    width = height * aspectRatio;
  }

  return {
    width: width,
    height: height
  };
}
function getAdjustedSizes(_ref4) // or 'cover'
{
  var aspectRatio = _ref4.aspectRatio,
      height = _ref4.height,
      width = _ref4.width;
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain';

  var isValidNumber = function isValidNumber(value) {
    return isFinite(value) && value > 0;
  };

  if (isValidNumber(width) && isValidNumber(height)) {
    var adjustedWidth = height * aspectRatio;

    if (type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width) {
      height = width / aspectRatio;
    } else {
      width = height * aspectRatio;
    }
  } else if (isValidNumber(width)) {
    height = width / aspectRatio;
  } else if (isValidNumber(height)) {
    width = height * aspectRatio;
  }

  return {
    width: width,
    height: height
  };
}
function getAdjustedSizes ( _ref4 ) // or 'cover' { var aspectRatio = _ref4 . aspectRatio , height = _ref4 . height , width = _ref4 . width ; var type = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 'contain' ; var isValidNumber = function isValidNumber ( value ) { return isFinite ( value ) && value > 0 ; } ; if ( isValidNumber ( width ) && isValidNumber ( height ) ) { var adjustedWidth = height * aspectRatio ; if ( type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width ) { height = width / aspectRatio ; } else { width = height * aspectRatio ; } } else if ( isValidNumber ( width ) ) { height = width / aspectRatio ; } else if ( isValidNumber ( height ) ) { width = height * aspectRatio ; } return { width : width , height : height } ; }
Get the max sizes in a rectangle under the given aspect ratio.
@param {Object} data - The original sizes.
@param {string} [type='contain'] - The adjust type.
@returns {Object} The result sizes.
Get the max sizes in a rectangle under the given aspect ratio .