Jcrop 中的一个错误,minSize +纵横比
我正在尝试在我的应用程序中使用 Jcrop,尽管我遇到了一个错误。我去了演示页面,那里也存在这个错误。以下是创建方法。
转到此演示页面 http://deepliquid.com/projects/Jcrop/demos.php?demo=advanced
确保选中以下选项 “可以移动选择”
“可调整大小的选择” 「纵横比」 “minSize/maxSize 设置”
创建一个选定区域,将其拖动到左上角,抓住选区的右下角(就像要调整其大小一样)并将其拖动到图像的左上角。
一旦您经过图像的左上角,选择区域就会向下折叠为 0x0 像素选择。
此错误仅在设置宽高比时发生。否则它工作正常。
我想知道是否有人有使用此插件的经验来修复此错误。我已经经历了一整天了,但还没有弄清楚。
- 编辑 - 在花了几个小时之后,我基本上修复了这个错误。我更改了以下代码。
// Magic %-)
if(xx >= x1) { // right side <-- Changed > to >=
if(xx - x1 < min_x) {
xx = x1 + min_x;
} else if (xx - x1 > max_x) {
xx = x1 + max_x;
}
if(yy > y1) {
yy = y1 + (xx - x1)/aspect;
} else {
yy = y1 - (xx - x1)/aspect;
}
} else if (xx <= x1) { // left side <-- Changed < to <=
if(x1 - xx < min_x) {
xx = x1 - min_x
} else if (x1 - xx > max_x) {
xx = x1 - max_x;
}
if(yy > y1) {
yy = y1 + (x1 - xx)/aspect;
} else {
yy = y1 - (x1 - xx)/aspect;
}
}
这阻止了它崩溃,但它仍然有点问题。
--编辑结束--
I am trying to use Jcrop for my application, though I have run into a bug with it. I went to the demo page, and the bug exists there too. Here is how to create it.
Go to this demo page
http://deepliquid.com/projects/Jcrop/demos.php?demo=advanced
Make sure the following options are checked
"Selection can be moved"
"Resizable selection"
"Aspect ratio"
"minSize/maxSize setting"
Create a selected area, drag it to the upper left corner, grab the lower right corner of the selection(as if you were going to resize it) and drag it to the upper left corner of the image.
Once you pass the upper left corner of the image the select area collapses down to a 0x0 pixel selection.
This bug only happens when an aspect ratio is set. Otherwise it works fine.
I'm wondering if anyone has any experience hacking around with this plugin to where they might be able to fix this bug. I've been going through it all day and haven't been able to figure it out yet.
--Edit--
After spending a few more hours with it I was able to get the bug mostly fixed. I changed the following code.
// Magic %-)
if(xx >= x1) { // right side <-- Changed > to >=
if(xx - x1 < min_x) {
xx = x1 + min_x;
} else if (xx - x1 > max_x) {
xx = x1 + max_x;
}
if(yy > y1) {
yy = y1 + (xx - x1)/aspect;
} else {
yy = y1 - (xx - x1)/aspect;
}
} else if (xx <= x1) { // left side <-- Changed < to <=
if(x1 - xx < min_x) {
xx = x1 - min_x
} else if (x1 - xx > max_x) {
xx = x1 - max_x;
}
if(yy > y1) {
yy = y1 + (x1 - xx)/aspect;
} else {
yy = y1 - (x1 - xx)/aspect;
}
}
This stopped it from collapsing, its still acts a little buggy though.
--End Edit--
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更稳定的版本似乎如下:
A more stable version seems to be the following:
这是我的补丁,我认为它比其他发布的补丁产生更好的行为。它特别消除的一件事是在演示中使用 minSize 并在边缘附近切换边时看到的弹出到边缘的情况。
Here's my patch, which I think produces better behavior than the others posted. One thing in particular it removes is the pop-to-edge seen in the demo when using minSize and switching sides near the edge.