dist/cropper.common.js
function setData$$1(data) {
    var options = this.options,
        imageData = this.imageData,
        canvasData = this.canvasData;

    var cropBoxData = {};

    if (this.ready && !this.disabled && isPlainObject(data)) {
      var transformed = false;

      if (options.rotatable) {
        if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
          imageData.rotate = data.rotate;
          transformed = true;
        }
      }

      if (options.scalable) {
        if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
          imageData.scaleX = data.scaleX;
          transformed = true;
        }

        if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
          imageData.scaleY = data.scaleY;
          transformed = true;
        }
      }

      if (transformed) {
        this.renderCanvas(true, true);
      }

      var ratio = imageData.width / imageData.naturalWidth;

      if (isNumber(data.x)) {
        cropBoxData.left = data.x * ratio + canvasData.left;
      }

      if (isNumber(data.y)) {
        cropBoxData.top = data.y * ratio + canvasData.top;
      }

      if (isNumber(data.width)) {
        cropBoxData.width = data.width * ratio;
      }

      if (isNumber(data.height)) {
        cropBoxData.height = data.height * ratio;
      }

      this.setCropBoxData(cropBoxData);
    }

    return this;
  }
function setData$$1(data) {
    var options = this.options,
        imageData = this.imageData,
        canvasData = this.canvasData;

    var cropBoxData = {};

    if (this.ready && !this.disabled && isPlainObject(data)) {
      var transformed = false;

      if (options.rotatable) {
        if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
          imageData.rotate = data.rotate;
          transformed = true;
        }
      }

      if (options.scalable) {
        if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
          imageData.scaleX = data.scaleX;
          transformed = true;
        }

        if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
          imageData.scaleY = data.scaleY;
          transformed = true;
        }
      }

      if (transformed) {
        this.renderCanvas(true, true);
      }

      var ratio = imageData.width / imageData.naturalWidth;

      if (isNumber(data.x)) {
        cropBoxData.left = data.x * ratio + canvasData.left;
      }

      if (isNumber(data.y)) {
        cropBoxData.top = data.y * ratio + canvasData.top;
      }

      if (isNumber(data.width)) {
        cropBoxData.width = data.width * ratio;
      }

      if (isNumber(data.height)) {
        cropBoxData.height = data.height * ratio;
      }

      this.setCropBoxData(cropBoxData);
    }

    return this;
  }
function setData$$1 ( data ) { var options = this . options , imageData = this . imageData , canvasData = this . canvasData ; var cropBoxData = { } ; if ( this . ready && ! this . disabled && isPlainObject ( data ) ) { var transformed = false ; if ( options . rotatable ) { if ( isNumber ( data . rotate ) && data . rotate !== imageData . rotate ) { imageData . rotate = data . rotate ; transformed = true ; } } if ( options . scalable ) { if ( isNumber ( data . scaleX ) && data . scaleX !== imageData . scaleX ) { imageData . scaleX = data . scaleX ; transformed = true ; } if ( isNumber ( data . scaleY ) && data . scaleY !== imageData . scaleY ) { imageData . scaleY = data . scaleY ; transformed = true ; } } if ( transformed ) { this . renderCanvas ( true , true ) ; } var ratio = imageData . width / imageData . naturalWidth ; if ( isNumber ( data . x ) ) { cropBoxData . left = data . x * ratio + canvasData . left ; } if ( isNumber ( data . y ) ) { cropBoxData . top = data . y * ratio + canvasData . top ; } if ( isNumber ( data . width ) ) { cropBoxData . width = data . width * ratio ; } if ( isNumber ( data . height ) ) { cropBoxData . height = data . height * ratio ; } this . setCropBoxData ( cropBoxData ) ; } return this ; }
Set the cropped area position and size with new data
@param {Object} data - The new data.
@returns {Cropper} this
Set the cropped area position and size with new data