【问题标题】:jsPlumb New Connection Handler: How to get the Endpoint anchor position?jsPlumb 新连接处理程序:如何获取端点锚点位置?
【发布时间】:2013-02-02 18:56:44
【问题描述】:

是的,所以我一直在玩 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
                          */
});

【问题讨论】:

    标签: jsplumb


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多