vue-cropper
vue-cropper copied to clipboard
自动裁剪全选时,有时候宽度会和高度一致
全选设置:autoCropWidth=99999 autoCropHeight=99999
debugger调试发现:
w=199.83909895414322 axis.x2-axis.x1 = 199.8390989541432
发现他们仅仅相差:0.00000000000002,就导致 w > axis.x2 - axis.x1,然后就会将h修改,导致高度和宽度一致。
源代码位置:
// 手动改变截图框大小函数
changeCrop(w, h) {
if (this.centerBox) {
// 修复初始化时候在centerBox=true情况下
let axis = this.getImgAxis();
if (w > axis.x2 - axis.x1) {
// 宽度超标
w = axis.x2 - axis.x1;
h = (w / this.fixedNumber[0]) * this.fixedNumber[1];
}
if (h > axis.y2 - axis.y1) {
// 高度超标
h = axis.y2 - axis.y1;
w = (h / this.fixedNumber[1]) * this.fixedNumber[0];
}
}