I use the Cropper JS library, and I am having some problems setting up data after the crop field after it is initialized.
https://github.com/fengyuanchen/cropper/blob/master/README.md http://fengyuanchen.imtqy.com/cropper/
I created a JSFiddle here http://jsfiddle.net/vs2merje/1/
My problem is that I want to change the following parameters {x, y, w, h} after initializing the cropping with a dynamic object.
var imageURL = "http://i.imgur.com/zIQ92.jpg"; var imageBox = $('.img-container img'); //Initial crop box settings. var options = { aspectRatio: 1/2 }; //If condition is met, create a dynamic settings object to reset the box. if(imageURL != null){ console.log("It not empty, building dedault box!"); var DefaultCropBoxOptionObj = { height: 25, width: 25 }; console.log(DefaultCropBoxOptionObj); imageBox.cropper(options); imageBox.cropper('setData', DefaultCropBoxOptionObj);//add the dynamic settings. imageBox.cropper('replace', imageURL); }
As you can see in JSFiddle, data from a dynamic window does not apply to a field with a height and width of 25 pixels.
Can anyone tell me why this is happening?
Thanks.
source share