React-diagrams: Prevent creation of extra Points on a Link

Created on 8 Sep 2020  路  1Comment  路  Source: projectstorm/react-diagrams

I need a listener to prevent creation of extra Points on a Link (all Points except the first and last one)
These Points
points

i used the linksUpdated listener but it doesn't fire when i create Point on a Link

answered needs demo question

Most helpful comment

If you want to customize how many points you can have in your link, you'll need to have a custom link set up in your project.

Once you have that, you can override addPoint method on YourLinkModel and add your logic. This is the default method inherited by LinkModel:

https://github.com/projectstorm/react-diagrams/blob/8ded9cd30e2d605c31f24270d38b1053dbda64dc/packages/react-diagrams-core/src/entities/link/LinkModel.ts#L289-L293

To prevent more than MAX_POINTS points on your link, you can override it with something like:

addPoint(pointModel, index) {
  if (this.points.length >= MAX_POINTS) return;
  return super.addPoint(pointModel, index);
}

>All comments

If you want to customize how many points you can have in your link, you'll need to have a custom link set up in your project.

Once you have that, you can override addPoint method on YourLinkModel and add your logic. This is the default method inherited by LinkModel:

https://github.com/projectstorm/react-diagrams/blob/8ded9cd30e2d605c31f24270d38b1053dbda64dc/packages/react-diagrams-core/src/entities/link/LinkModel.ts#L289-L293

To prevent more than MAX_POINTS points on your link, you can override it with something like:

addPoint(pointModel, index) {
  if (this.points.length >= MAX_POINTS) return;
  return super.addPoint(pointModel, index);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jardg picture jardg  路  3Comments

shortwavedave picture shortwavedave  路  3Comments

affanshahid picture affanshahid  路  3Comments

msaglietto picture msaglietto  路  3Comments

M2Costa picture M2Costa  路  3Comments