最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论