当框大小小于允许的最小图像大小时,我正在尝试实现自动调整大小或裁剪框,现在我做了这个:
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;
}
但是想对cropend
处理的事件进行此计算:
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);
}
});
我的问题是:如何从事件中获取裁剪器实例?