jQuery的Jcrop setSelect直观地显示了,但是当点击移动,它跳跃直观、jQuery、Jcrop、setSelect

由网友(刺心的痛)分享简介:我现在用的是jQuery插件Jcrop。我有一个问题,叫setSelect初始设置设置之一。I am using the jQuery plugin Jcrop. I have an issue with one of the initial setup settings called setSelect.该属性采...

我现在用的是jQuery插件Jcrop。我有一个问题,叫setSelect初始设置设置之一。

I am using the jQuery plugin Jcrop. I have an issue with one of the initial setup settings called setSelect.

该属性采用的两套X和Y坐标(左上角和右下角)的数组。

The property takes in an array with two sets of x and y coordinates (top left corner, and bottom right corner).

<img src="blah" id="cropTool" />
<script type="text/javascript">
    $(function()
    {
        $('#cropTool').Jcrop(
        {
            setSelect: [
                $('#cropTool').width()/4,
                $('#cropTool').height()/4,
                ($('#cropTool').width()/4)*3,
                ($('#cropTool').height()/4)*3
            ]
        });
    });
</script>

在视觉上这不正是我所期望的。它把同的方式左上角1 /第四裁剪选择到图像(x和y)和的方式进入从图像的底部右侧的图像的右下角的1/4日。像这样的:

Visually this does exactly what I expect. It places a crop selection with the top left corner 1/4th of the way into the image (x and y) and the bottom right corner 1/4th of the way into the image from the bottom right of the image. Like this:

但后来当我去移动它,它跳转到这个位置:

But then when I go to move it, it jumps to this position:

这立即跳到那里,我不拖着它。如果我尝试将其拖动跳转默认选择一个像素或多个移动之后。它跳跃后,我可以正常移动它。这是一个有点小问题,但很是烦人。

It jumps there immediately, I'm not dragging it there. If I try to drag the default selection it jumps after moving it by one pixel or more. After it jumps I can move it around normally. It's a somewhat minor issue, but it is annoying.

任何想法?

推荐答案

打开了另一个jQuery插件,我用的是被干扰了jcrop定位。一个插件叫做颜色框,加载覆盖弹出窗口是问题。我打电话jQuery.colorbox.resize()之前,我在呼唤jcrop。当jcrop code跑了调整大小,从来没有完全完成。一个解决办法是把jcrop code到的setTimeout()耽误code一秒钟。这是hackish的解决方案,所以我问另外一个更具体的问题并得到答案。原来颜色框的另一个派生包含修复,包括对大小调整方法的回调函数,这样你可以执行code当调整大小完成。

Turns out another jQuery plugin I was using was interfering with the jcrop positioning. A plugin called colorbox which loads overlay popups was the issue. I was calling jQuery.colorbox.resize() right before I was calling jcrop. When the jcrop code ran the resize was never quite complete. One solution was to put the jcrop code into a setTimeout() to delay the code for a second. That was hackish solution so I asked another more specific question and got an answer. Turns out another fork of colorbox contains a fix to include a function callback on the resize method so that you can execute code when the resize is complete.

jQuery回调等待code,以完成移动之前执行?

阅读全文

相关推荐

最新文章