fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

setCropBoxData method doesn't work #1035

Closed WebTravel closed 5 years ago

WebTravel commented 5 years ago

I have next code

this.cropper = new Cropper(this.$element, {
      viewMode: 2,
      dragMode: 'move',
      autoCrop: false,
      autoCropArea: 1,
      restore: false,
      cropBoxMovable: false,
      cropBoxResizable: false,
      toggleDragModeOnDblclick: false,
      zoomOnWheel: false,
      zoomOnTouch: false,
      background: false,
      ready() {
        this.cropper.setCropBoxData({ left: 0 }); // not working
        this.cropper.cropBoxData.left = 0; // also not working
        this.cropper.crop();
        console.log(this.cropper.cropBoxData); // I get same values, when I don't use method above
      },
 });
WebTravel commented 5 years ago

I decided my problem. setCropBoxData will to work affter cropper.crop()

ready() {
        this.cropper.crop();
        this.cropper.setCropBoxData({ left: 0 });
        console.log(this.cropper.cropBoxData); // it's working because I use method setCropBoxData after cropper.crop();
},