javascript - change edges line color when the connected node clicked in cytoscape.js - Stack Overflow

could someone give an example of Cytoscape.js about a node that when it clicked, the neighbors edges ch

could someone give an example of Cytoscape.js about a node that when it clicked, the neighbors edges changed its styles.

this code doesn't work:

cy.$('node:selected').neighborhood('edge').style({
  'line-color': 'black'
});
cy.$('node:selected').connectedEdges().style({
  'line-color': 'black'
});

could someone give an example of Cytoscape.js about a node that when it clicked, the neighbors edges changed its styles.

this code doesn't work:

cy.$('node:selected').neighborhood('edge').style({
  'line-color': 'black'
});
cy.$('node:selected').connectedEdges().style({
  'line-color': 'black'
});

Share Improve this question edited Feb 22, 2022 at 4:58 Dendi Handian asked Mar 1, 2016 at 4:51 Dendi HandianDendi Handian 3743 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6
cy.$('node').on('grab', function (e) {
    var ele = e.target;
    ele.connectedEdges().style({ 'line-color': 'red' });
});


cy.$('node').on('free', function (e) {
    var ele = e.target;
    ele.connectedEdges().style({ 'line-color': '#FAFAFA' });
});

You have a race condition by assuming the order of events of tap/click and select.

Use :selected selectors for querying only with select events or use tap with the element passed in the event object.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745110715a4611833.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信