使用此处的断头台插件Guillotine Plugin
你只能缩小到最适合的状态。允许这样,如果你在一个信箱裁剪区域上有一个正方形的上传图像,你就无法缩小以查看整个正方形..两边必须到达信箱的边缘。
是否可以让插件进一步缩小,从而产生负缩放值,这需要在后台进行图像处理以添加空白区域。
由于
答案 0 :(得分:1)
似乎没有任何允许负缩放的选项,所以我在源代码中探讨了一下,你可以更改/注释掉这些行来实现这一点。
也这样做'休息'拖动限制使图像不再捕捉到裁剪区域的边缘。
这是偏移函数的变化
Guillotine.prototype._offset = function(left, top) {
if (left || left === 0) {
if (left < 0) {
//I HAVE REMOVED THIS SO THAT WE CAN MOVE A SHRUNKEN IMAGE AROUND
//left = 0;
}
if (left > this.width - 1) {
//I HAVE REMOVED THIS SO THAT WE CAN MOVE A SHRUNKEN IMAGE AROUND
//left = this.width - 1;
}
this.canvas.style.left = (-left * 100).toFixed(2) + '%';
this.left = left;
this.data.x = Math.round(left * this.op.width);
}
if (top || top === 0) {
if (top < 0) {
//I HAVE REMOVED THIS SO THAT WE CAN MOVE A SHRUNKEN IMAGE AROUND
//top = 0;
}
if (top > this.height - 1) {
//I HAVE REMOVED THIS SO THAT WE CAN MOVE A SHRUNKEN IMAGE AROUND
//top = this.height - 1;
}
this.canvas.style.top = (-top * 100).toFixed(2) + '%';
this.top = top;
return this.data.y = Math.round(top * this.op.height);
}
};
这是缩放功能的变化
//REPLACE BELOW LINE TO ALLOW NEGATIVE ZOOMS IE DONT BEST FIT
//if (w * factor > 1 && h * factor > 1) {
if (w * factor > 0 && h * factor > 0) {