I'm trying to realize auto resizing or cropbox when box size less than minimum allowed image size, for now I made this:
var cropper = document.getElementById('image_cropper').cropper;
if (!cropper instanceof Cropper) {
console.warning('cropper not initialized');
return false;
}
var data = cropper.getData();
if (data.width < app.avatar.min_width || data.height < app.avatar.min_height) {
data.width = app.avatar.min_width;
data.height = app.avatar.min_height;
cropper.setData(data);
return;
}
But want to do this calc on cropend
event handled:
canvas.addEventListener('cropend', function (event) {
var data = cropper.getData();
if (data.width < app.avatar.min_width || data.height < app.avatar.min_height) {
data.width = app.avatar.min_width;
data.height = app.avatar.min_height;
cropper.setData(data);
}
});
And my question is: how can I get cropper instance from event?