我如何才能将使用cytoscape.js在单个动画在特定方向上的所有节点?

问题描述 投票:0回答:1

我想要做这样的事情:

cy.nodes().animate({
    position: { x: x + 100, y: y + 100 },
});

但是,这并不工作。我根本不知道如何访问节点的当前位置。我想,我只是简单的东西在这里。

javascript animation position cytoscape.js
1个回答
1
投票

我想你可以实现你想要使用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演示(按动画按钮)。

© www.soinside.com 2019 - 2024. All rights reserved.