react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

Allow links based on port types

Open affanshahid opened this issue 8 years ago • 3 comments

Would it be possible currently to have multiple 'types' of input and output ports so that only certain outputs can link with certain inputs.

So something like: An input Inp1 which has type IA and thus only allows connections with outputs of types OA

affanshahid avatar Nov 02 '18 19:11 affanshahid

It's a pretty easy extension of the library, I acheived this by overloading the canLinkToPort(port: SimPortModel): boolean function in my extension of PortModel. You can then add your type to this in your constructor, and implement whatever connection as to whether connection is allowed through canLinkToPort.

Good luck!

cullenmcmahon avatar Nov 08 '18 19:11 cullenmcmahon

@cullenmcmahon Thank you for the info, this worked nicely for a specific type of link for my "top" port.

canLinkToPort(port) { if (port.type === "PortTypeStr" && this.position === "top") { return true; } return false; }

miguel1velazquez avatar Nov 15 '18 21:11 miguel1velazquez

https://projectstorm.gitbook.io/react-diagrams/customizing/ports

dylanvorster avatar Aug 11 '19 14:08 dylanvorster