【发布时间】:2023-03-30 20:37:01
【问题描述】:
我正在尝试使用 Jcrop 裁剪图像,但是当我在图像上使用 jqueryrotate 时,会发生一些奇怪的事情。
我将图像旋转 90 度然后激活 JCrop,JCrop 不跟随旋转的图像,所以我也旋转了 Jcrop-holder。生成的图像还可以,但是当我选择要裁剪的部分时,我注意到我的跟踪器也旋转了。往上拖是往右,往左拖是往下。
会发生什么
然后就可以了 如何让作物选择工具保持直立?
我的html:
<div class="img-canvas" style="background-color:#cccccc;" >
<img id="image_canv" src="<?php echo $imagesource;?>">
</div>
我的 Jquery:
$('#rotatephoto').click(function () {
value += 90;
JcropAPI = $('#image_canv').data('Jcrop');
if(JcropAPI != null)
{
JcropAPI.destroy();
}
var h = $('.img-canvas').height();
var w = $('.img-canvas').width();
$('.img-canvas').css("position","fixed");
$('.img-canvas').css("width",w);
$('.img-canvas').css("height",h);
$('#image_canv').Jcrop({
onSelect: showCoords2,
onChange: showCoords2,
setSelect: [ 0, 100, 50, 50 ]
});
JcropAPI = $('#image_canv').data('Jcrop');
JcropAPI.enable();
var h2 = $('.jcrop-holder').height();
var w2 = $('.jcrop-holder').width();
if(h2 < 630)
{
var tempp = (630 - h2)/2;
$('.jcrop-holder').css("margin-top",tempp);
}
if(w2 < 630)
{
var tempp = (630 - w2)/2;
$('.jcrop-holder').css("margin-left",tempp);
}
$('.jcrop-holder').rotate(value);
$("#image_canv").rotate(value);
});
【问题讨论】:
标签: jquery image rotation crop jcrop