2014-04-15 55 views
0
的最小高度和宽度

我一组的邮件模板,它可以让用户如果用户想在的特定区域添加图像添加文字,图像,改变字体和颜色等。现在工作模板,他们将首先点击他们想要添加图像的区域,然后在我的应用程序中添加库中的图像。现在让我们考虑一下,他们在模板上点击的区域的可接受尺寸是500 * 500,从库中选择的图像是1000 * 1000,在这种情况下,应用程序会自动调出一个可以调整大小的裁剪工具图片。但是,我想限制裁剪工具只能拖动到模板中所需位置的最小高度或宽度,即在此示例中,它们不应该能够在高度或宽度以下拖动裁剪工具尽管它们可以保持一个或两个尺寸在500以上,因为裁剪工具自动调整尺寸为500×500(例如800×500或甚至500×1000也是可接受的,因为裁剪工具自动调整图像的大小以适合在模板中)。我看了一下documentationthis question,但是找不到合适的答案来回答我的问题。下面是我的一些代码验证如果图像需要进行裁剪:设置上JCrop

var SelectedAreaHeight; //returns the height of the area they clicked on the template 
var SelectedAreaWidth; //returns the width similarly 

function ImageClick(data) 
{ 
var ReturnImageHeight; //returns the height of the area they clicked on 
var ReturnImageWidth; //returns the width similarly 

    $(".ResizeImage").each(function() 
    { 
     ReturnImageHeight = $(this).data("height"); 
     ReturnImageWidth = $(this).data("width"); 
    } 
    }); 

    if (ReturnImageHeight > SelectedAreaHeight || ReturnImageWidth > SelectedAreaWidth) 
    { 
     //this checks if the selected image's height OR width is greater 
     //than the desired area in the template to bring up the cropping tool. 
    } 
} 

现在有没有一种方法,我可以只限制的方式裁剪工具,它是不低于SelectedAreaHeight OR SelectedAreaWidth“作物能够” ?同样请忽略上面示例代码的任何问题,因为我没有粘贴所有的代码(它不仅仅是这些)。

回答

7

Ekhm:d 有在jcrop :)

http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options

minSize属性这样的选项:阵列[W,H]:最小宽度/高度,对于无界 维度n使用0 /一个

+0

我要发布此程为答案,当我碰到它,但我不能回答我的问题在接下来的8小时。无论如何,谢谢:) –

+0

好吧:)太糟糕了,你失去了一些你的时间。 :D下一次使用手动谷歌或ctrl + f:D 我已经与谷歌创建解决方案。 :)我已经使用jcrop,但从来不需要这样的选项。 <3 jcrop - 酷插件。 –

+0

当然,我会再次感谢。 JCrop很酷,我同意! :d –