2017-03-27 10 views
0

これまで検査したことから、リンクのターゲットは決してnullではないため、問題が発生しています。私はあるポイント(オブジェクト)に私のリンクに参加するときにイベントをトリガーしたい、私はそれを動かすたびに何かに接続しないようにトリガーしたくない。その変更イベントを無効にする方法はありますか?リンクをドラッグしたら変更をトリガーするJointJSリンクの変更:毎回ターゲットのトリガー

this.graph.on('change:target', function(cell) { 
    if (cell.isLink()) { 
    // Any code here will trigger every time I drag my link 
    // There is no way I can add if else here to solve my problem 
} 
}); 

答えて

0

解決策が見つかりました。私は私の目的のために間違ったハンドラを使用していた。グラフハンドラを使う代わりに、私は紙のハンドラを使わなければなりませんでした。

'セル:pointerup' -

this.paper.on('cell:pointerup', function(cellView, event) { 
    var cell = cellView.model; 
    if (cell.isLink()){ 
     if (cell.get('source').id ==null || cell.get('target').id == null) { 
     cell.remove(); 
     } 
    } 
    }); 
0

これを試してみポインタが紙にリリースされたときにトリガ:

paper.on('link:disconnect', function(linkView, evt, disconnectedFromView, magnetElement, type) { 
    console.log('link:disconnect', type, disconnectedFromView, magnetElement); 
}); 

paper.on('link:connect', function(linkView, evt, connectedToView, magnetElement, type) { 
    console.log('link:connect', type, connectedToView, magnetElement); 
}); 
関連する問題