1
JointJSでポートから描画するかハローを使用するのではなく、参照点(x、y)から対話的なダイナミックリンクを作成できますか?ポインタダウンイベントでダイナミックリンクを作成する-JointJS
よろしく Achyut
JointJSでポートから描画するかハローを使用するのではなく、参照点(x、y)から対話的なダイナミックリンクを作成できますか?ポインタダウンイベントでダイナミックリンクを作成する-JointJS
よろしく Achyut
これを解決するのに役立つかもしれないJointJSでいくつかのドキュメント化されていない方法があります。より多くのインライン。
paper.on('blank:pointerdown', function(evt, x, y) {
var linkView = this.getDefaultLink()
.set({
'source': { x: x, y: y },
'target': { x: x, y: y }
})
.addTo(this.model)
.findView(this);
// initiate the linkView arrowhead movement
linkView.startArrowheadMove('target');
$(document).on({
'mousemove.example': onDrag,
'mouseup.example': onDragEnd
}, {
// shared data between listeners
view: linkView,
paper: this
});
function onDrag(evt) {
// transform client to paper coordinates
var p = evt.data.paper.snapToGrid({
x: evt.clientX,
y: evt.clientY
});
// manually execute the linkView mousemove handler
evt.data.view.pointermove(evt, p.x, p.y);
}
function onDragEnd(evt) {
// manually execute the linkView mouseup handler
evt.data.view.pointerup(evt);
$(document).off('.example');
}
});
ありがとうございました!!!それは魅力のように働いています。私はJavascriptとJointJSの新人です。 mousemoveとmouseupのそれぞれの関数が呼び出されたことを理解できました。しかし、どのように使用されていますか?マウスイベントに.exampleを割り当てることの重要性は何ですか? – ACHU
デモが正しく動作することは重要ではありません。私は[namespaces](https://api.jquery.com/event.namespace/)を 'onDragEnd()'の 'mousemove'と' mouseup'リスナーの両方を参照するためにのみ使用しました。 – Roman
うん!わかった。私はそれがマウスイベントを参照するために使用される名前空間だと思います。 – ACHU