简体   繁体   English

Cytoscape.js动画节点颜色

[英]Cytoscape.js Animate Node Color

I'm trying to understand more about the Cytoscape.js animate. 我试图了解有关Cytoscape.js动画的更多信息。 Looking at the documentation here , if I understand that properly it should change the node color to blue over a second, wait a second, and then change the node color to yellow. 查看此处的文档,如果我理解正确的话,应将节点颜色在一秒钟内更改为蓝色,请稍等片刻,然后将节点颜色更改为黄色。 However, when I hit the button to view the example it doesn't do anything. 但是,当我点击按钮查看示例时,它什么也没做。

I tried to do something similar in my own code here: 我尝试在自己的代码中执行类似的操作:

$(function() {
    $('#cy').cytoscape({
        style: cytoscape.stylesheet()
            .selector('node')
                .css({
                    'content': 'data(name)',
                    'text-valign': 'center',
                    'color': 'black'
                }),

        ready: function(){
            window.cy = this;

            cy.add({
                group: 'nodes',
                data: {name: 'test', id: '1'},
                position: {x: 200, y: 100}
            });

            cy.nodes().animate({
                style: {
                    'background-color': 'blue'
                }
            }, {
                duration: 2000,
                complete: function() {
                    console.log("Done");
                }
            });
        }
    });
});

but again the color doesn't change any. 但是颜色还是不变的

Ultimately I'm hoping to use the animate and style to animate changing the size of a node, but I was just trying to figure out the basics of animating it and got stuck here. 最终,我希望使用动画和样式来动画化节点的大小,但是我只是想弄清楚对其进行动画处理的基本知识,并被困在这里。 Thanks in advance for the help! 先谢谢您的帮助!

It looks like the style alias isn't working. style别名似乎无效。 Try css in place of style until fixed: 尝试使用css代替style直到修复:

https://github.com/cytoscape/cytoscape.js/issues/1047 https://github.com/cytoscape/cytoscape.js/issues/1047

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM