Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge.segmentPoints() and controlPoints() return undefined immediately after adding an edge. #3267

Open
7 tasks
feel0321 opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
bug A bug in the code of Cytoscape.js PR There is a PR associated with this issue
Milestone

Comments

@feel0321
Copy link

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.

  1. edge.segmentPoints() method returns array with using setTimeout
// this is array
setTimeout(() => console.log(edge.segmentPoints()))
  1. edge.segmentPoints() method returns array after edge.midpoint(). you can check my jsbin link.

  2. I found an issue ( Edge points are undefined immediately after edge is added #2250) and pr (d0d70c2)

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

  1. you can see undefined in console.
  2. 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.x if the current release is 1.2).
  • The issue has been labelled as a bug, if necessary.
@feel0321 feel0321 added the bug A bug in the code of Cytoscape.js label Aug 12, 2024
@maxkfranz maxkfranz added this to the 3.30.3 milestone Aug 14, 2024
@maxkfranz maxkfranz self-assigned this Aug 19, 2024
@mikekucera mikekucera self-assigned this Sep 17, 2024
@mikekucera mikekucera added the PR There is a PR associated with this issue label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in the code of Cytoscape.js PR There is a PR associated with this issue
Projects
None yet
Development

No branches or pull requests

3 participants