gpt4 book ai didi

javascript - 图像区域选择 : cancel new selection if selection already exists

转载 作者:行者123 更新时间:2023-12-03 12:24:34 26 4
gpt4 key购买 nike

如果选择已存在,我想取消"new"选择。我尝试在 onSelectStart 上返回 false 并没有像我预期的那样工作。

我怎样才能实现这一目标?

代码示例如下:

currentCoords = {
x1: $('input[name="thumb-x1"]')
};

selectthumb = $('.img-orig-thumb').imgAreaSelect({
instance: true,
handles: true,
aspectRatio: '1:1',
imageWidth: <?php echo $imgsize[0]; ?>,
imageHeight: <?php echo $imgsize[1]; ?>,
onSelectStart: function(img, selection) {
_selection = parseInt(currentCoords.x1.val());
if(_selection > 0) return false;
}
});

最佳答案

您可以执行的唯一操作是重置 imgAreaSelect

var options = {
instance : true,
handles : true,
aspectRatio : '1:1',
imageWidth : <?php echo $imgsize[0]; ?>,
imageHeight : <?php echo $imgsize[1]; ?>,
onSelectStart : function(img, selection) {
_selection = parseInt(currentCoords.x1.val());
if(_selection > 0){
$(img).imgAreaSelect({remove:true});
$(img).imgAreaSelect(options);
return;
};
}
}

selectthumb = $('.img-orig-thumb').imgAreaSelect(options);

关于javascript - 图像区域选择 : cancel new selection if selection already exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24273473/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com