4

是的,所以我一直在玩 jsPlumb。假设我有一个带有两个端点的 div;一个顶部中心,一个底部中心。

创建新连接后,我可以使用以下函数绑定到该事件。我的问题是,如何获得端点的锚点位置?我确实得到了 Source 和 TargetEndpoint 对象,但是查看文档,我看不到获取锚点位置的方法......

谢谢!

jsPlumb.bind("jsPlumbConnection", function(connectionInfo) {
 /*
                         connection         :   the new Connection.  you can register listeners on this etc.
                        sourceId        :   id of the source element in the Connection
                          targetId      :   id of the target element in the Connection
                          source        :   the source element in the Connection
                          target        :   the target element in the Connection
                          sourceEndpoint    :   the source Endpoint in the Connection
                          targetEndpoint    :   the targetEndpoint in the Connection
                          */
});
4

2 回答 2

5

connectionInfo.connection.endpoints[0].anchor.type是源位置。 connectionInfo.connection.endpoints[1].anchor.type是目标位置。

于 2013-03-19T16:08:19.043 回答
1

我找到了以下问题的解决方案:console.log('anchors: %o %o',connectionInfo.sourceEndpoint.anchor.x, connectionInfo.sourceEndpoint.anchor.y);

通过获取端点的 x 和 y 坐标,我知道锚点的位置,并且可以使用它来重新创建图表。

于 2013-02-03T14:21:32.793 回答