0
如何将rendered position转换为model position?Cytoscape.js:将渲染位置转换为模型位置
例子:
var rpos = cy.pan();
var mpos = cy.toModelPosition(rpos); // Get top left corner position in model
据我所知,在doc没有提到任何转换方法。我相信它会超级有用!
当然,我可以写自己的东西:
function toModelPosition(pos) {
return {
x: (pos.x - cy.pan().x)/cy.zoom(),
y: (pos.y - cy.pan().y)/cy.zoom(),
};
}