projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.61k stars 1.17k forks source link

How to make the nodes not draggable? #647

Closed vickyvishal closed 4 years ago

vickyvishal commented 4 years ago

I understand that model.setLocked(true) will make it not draggable but we cannot initiate a link from its ports. Is there a way to make the nodes not draggable but the port can initial a link?

TIA

renato-bohler commented 4 years ago

Hmm... apparently there's a configuration that does exactly that.

https://github.com/projectstorm/react-diagrams/blob/361fbe4ffed7d5b485c9d7e871cf891c55d6c4d7/packages/react-diagrams-core/src/states/DragNewLinkState.ts#L44-L47

It defaults to false, but you can change it by doing this:

const state = engine.getStateMachine().getCurrentState();
state.dragNewLink.config.allowLinksFromLockedPorts = true;

Please note that I've never seen this before, so I'm not sure it works hehe

malavshah-9 commented 2 years ago

@renato-bohler Can you give here details example or something which i can implement.

Thanks in advance