Edge.segmentPoints() and controlPoints() return undefined immediately after adding an edge.
Before you post
A request for help or a request for a how-to should be directed to Phind.
If your issue pertains to an extension, your issue should be filed in that extension's repository -- not here.
Environment info
- Cytoscape.js version : 3.31.0-unstable
- Browser/Node.js & version : Chrome 127.0.6533.89 / Node v18.17.0
Current (buggy) behaviour
I want to get segmentPoint or controlPoint immediately after edge is added.
but edge.segmentPoints() and edge.controlPoints() method returns undefined when immediately after edge is added.
this is my checked.
-
edge.segmentPoints()method returns array with usingsetTimeout
// this is array
setTimeout(() => console.log(edge.segmentPoints()))
-
edge.segmentPoints()method returns array afteredge.midpoint(). you can check my jsbin link. -
I found an issue ( #2250) and pr (https://github.com/cytoscape/cytoscape.js/commit/d0d70c20f7e2cfa4d87e6c44be82aed4d30607ab)
I think segments and unbundled-bezier edge required recalculateRenderedStyle().
I test a little bit, it returns array
BRp$c.getSegmentPoints = function( edge ){
// add line
this.recalculateRenderedStyle( edge );
let rs = edge[0]._private.rscratch;
let type = rs.edgeType;
if( type === 'segments' ){
// this.recalculateRenderedStyle( edge );
return getPts( rs.segpts );
}
};
but it's my first issue. so I have no confidence. how about this?
Desired behaviour
edge.segmentPoints() and edge.controlPoints() method should return array immediately after the edge is added.
Minimum steps to reproduce
https://jsbin.com/ruqahuc/1/edit?html,js,output
- you can see
undefinedin console. - if you remove midpoint() comment, you can see array in console.
For reviewers
Reviewers should ensure that the following tasks are carried out for incorporated issues:
- [ ] Ensure that the reporter has included a reproducible demo. They can easily fork this JSBin demo: http://jsbin.com/fiqugiq
- [ ] The issue has been associated with a corresponding milestone.
- [ ] The commits have been incorporated into the corresponding branches. Bug-fix patches go on
- [ ]
master, - [ ]
unstable, and - [ ] the previous feature release branch (e.g.
1.1.xif the current release is 1.2).
- [ ]
- [ ] The issue has been labelled as a
bug, if necessary.