2014-03-24 45 views
0

我想完成的是我可以旋转jsplumb连接。你可以使用setAnchor来重新定义一个Anchor,但是我不能让它工作。我发现这个在线,它的工作原理,但它不是我想要的。Jsplumb更改静态锚的位置

jsPlumb.selectEndpoints("myclickedelement").setAnchor([ "Continuous", { faces: ["Top", "Bottom", "Left", "Right"] }]) 

我上了对象的顶部和底部的终点,当我旋转它,我想他们是在左,右,但不删除现有的连接。

  jsPlumb.addEndpoint($(this).parent("div").attr('id'),  { anchor:[0.5, 0, 0, -1] }, 
{ isSource:true, 
isTarget:true, 
paintStyle:{ lineWidth:1, strokeStyle:'#ff8700' }, 
connector: 'Flowchart', 
hoverPaintStyle:{ strokeStyle:"#ff8700", lineWidth:4}, 
    }) 
jsPlumb.addEndpoint($(this).parent("div").attr('id'), { anchor:[0.5, 1, 0, 1] }, 
{ isSource:true, 
isTarget:true, 
paintStyle:{ lineWidth:1, strokeStyle:'#ff8700' }, 
connector: 'Flowchart', 
hoverPaintStyle:{ strokeStyle:"#ff8700", lineWidth:4}, 
    }) 

这就是我要创建我的锚对象

回答

0

我已经找到了解决办法

endpoints = jsPlumb.selectEndpoints($(this).attr('id').elementId); 
anchorarray = [[0.5,0,0,-1],[1,0.5,1,0],[0.5,1,0,1],[0,0.5,-1,0]]; 

endpoints.each(function(ep){ 
    if (top == 0 && ep.id.contains(clickeditem)) { 
      ep.setAnchor(anchorarray[0]); 
      top = 1; 

     } else if (ep.id.contains(clickeditem)) { 
      ep.setAnchor(anchorarray[2]); 
     } 
});