我想要做这样的事情:
cy.nodes().animate({ position: { x: x + 100, y: y + 100 }, });
但是,这并不工作。我根本不知道如何访问节点的当前位置。我想,我只是简单的东西在这里。
我想你可以实现你想要使用preset布局什么:
preset
cy.nodes().layout({ name: 'preset', animate: true, fit: false, transform: (node) => { let position = {}; position.x = node.position('x') + 100; position.y = node.position('y') + 100; return position; } }).run();
有关更多选项见doc。
这里是一个JS Bin演示(按动画按钮)。