2015-12-31 145 views
0

有人可以告訴我如何檢查在JCrop中是否選擇了裁剪區域?JCrop檢查區域選擇

希望在API中有一個布爾函數,但我沒有看到這樣的事情。我嘗試過使用updatecoords函數,但是即使沒有選擇選擇,也設置x,y,w和h。

這裏是我的實例:

var jcrop_api; 
$('#profile_crop').Jcrop({onSelect: updateCoords, setSelect: [0, 542, 671, 0], boxWidth: 542, boxHeight: 671, aspectRatio: 542/671}, 
    function() { 
     jcrop_api = this; 
    }); 

回答

0

你就要有當有選擇手動檢測,所以使用 onRelease處理程序。從API:

var jcrop_api; 
var selected; 
$('#profile_crop').Jcrop({onSelect: showCoords, onRelease: releaseCoords, setSelect: [0, 542, 671, 0], boxWidth: 542, boxHeight: 671, aspectRatio: 542/671}, 
    function() { 
    jcrop_api = this; 
    } 
); 

function showCoords(c){ 
    selected = true; 
    // variables can be accessed here as 
    // c.x, c.y, c.x2, c.y2, c.w, c.h 
}; 

function releaseCoords(c){ 
    selected = false; 
    // variables can be accessed here as 
    // c.x, c.y, c.x2, c.y2, c.w, c.h 
}; 

我知道如果我沒有回答你的問題!