jCrop un 克制比例
jCrop un restrain proportions
我在.NET MVC4中构建了一个图像上传和裁剪应用程序,并具有我在deepliquid中找到的以下代码.com.Aas作为MVC开发人员,我有该部分工作,但我的javascript还有很多不足之处。下面的代码约束比例,如何更新它,使其不约束比例但仍保留预览?
<script type="text/javascript">
jQuery(function ($) {
// Create variables (in this scope) to hold the API and image size
var jcrop_api,
boundx,
boundy,
// Grab some information about the preview pane
$preview = $('#preview-pane'),
$pcnt = $('#preview-pane .preview-container'),
$pimg = $('#preview-pane .preview-container img'),
xsize = $pcnt.width(),
ysize = $pcnt.height();
$('#target').Jcrop({
onChange: updatePreview,
onSelect: updatePreview,
**aspectRatio: xsize / ysize**
}, function () {
// Use the API to get the real image size
var bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];
// Store the API in the jcrop_api variable
jcrop_api = this;
// Move the preview into the jcrop container for css positioning
$preview.appendTo(jcrop_api.ui.holder);
});
function updatePreview(c) {
if (parseInt(c.w) > 0) {
var rx = xsize / c.w;
var ry = ysize / c.h;
$pimg.css({
width: Math.round(rx * boundx) + 'px',
height: Math.round(ry * boundy) + 'px',
marginLeft: '-' + Math.round(rx * c.x) + 'px',
marginTop: '-' + Math.round(ry * c.y) + 'px'
});
}
};
});
</script>
知道了,只需删除
aspectRatio: xsize / ysize
相关文章:
- JCROP更改图像时重置纵横比
- Jcrop未在加载的图像上初始化
- 使用Jcrop和Pixastic进行裁剪
- Jcrop&画布:裁剪区域的大小很奇怪;500内部服务器错误
- No puedo comparar una variable con un cadena de tipo String
- Jcrop预览已移动
- 如何使用jcrop裁剪不同大小的图像
- 缩小后的大图像上的Jcrop圆形选择显示预览选择区域中的全尺寸图像
- 如何使用getOptions在Jcrop中检索truesize数组值
- JCrop使用集合选择选项时插件已损坏
- 按下esc键或随机单击鼠标时,Jcrop失去焦点
- 在单击按钮时设置 JCrop 的纵横比
- 在文档加载时禁用 JCrop
- Jcrop:设置图像后,jcrop在应用新图像时不采用TrueSize
- 如何在 Jcrop 中禁用纵横比
- JCrop:将文本添加到选择区域 - 可能
- jCrop un 克制比例
- 如何在使用 jCrop 时删除 setSelect()
- 取消选择所有复选框时出现问题 Un 选中子项之一
- Jcrop将旋转集成到其中