2014-06-17 59 views
0

如果选择已存在,我想取消我的“新”选择。我在onSelectStart上返回false的尝试不像我期望的那样工作。imgareaselect:如果已经存在选择,则取消新选择

我怎么能做到这一点?

代码下面的例子:

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; 
    } 
}); 

回答

1

,你唯一可以做的动作是复位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); 
相关问题