0
我使用此代码来选择需要裁剪的图像区域。JavaScript图像裁剪问题
function preview(img, selection) {
var scaleX = 100/selection.width;
var scaleY = 100/selection.height;
$('#thumbnail + > img').css({
width: Math.round(scaleX * 354) + 'px',
height: Math.round(scaleY * 448) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('#y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}
$(window).load(function() {
$('#thumbnail').imgAreaSelect({ x1: 120, y1: 90, x2: 280, y2: 210, aspectRatio: '1:1', onSelectChange: preview });
});
这工作正常,但我使用制表符显示不同的部分。当我点击下一个标签时,我可以看到我不想要的图像裁剪器。我该如何解决这个问题?
我看到你使用$函数,但这不是标准的JavaScript。如果您正在使用Prototype,JQuery,Dojo或其他JavaScript框架,那么您应该在问题中提到这一点。另外,尝试将代码放在代码块中(请参阅编辑器面板顶部的按钮) – 2009-04-10 18:27:00