How to make cropper js cropBox equal to container size. In other words the cropbox area should be equal to the available area of the preview height and width.
A better solution maybe setting autoCropArea as 1
{ autoCropArea: 1}
I found the solution a while ago, and I just realized that I had not answered this question.
The way I managed to set the full width was:
var image = document.getElementById('image');
var cropper = new Cropper(image, {
aspectRatio: 16 / 9,
crop: function(e) {
console.log(e.detail.width);
console.log(e.detail.height);
}
});
var contData = cropper.getContainerData(); //Get container data
cropper.setCropBoxData({ height: contData.height, width: contData.width }) //set data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With