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
2 Answers
Reset to default 6cy.$('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条)