strathausen / dracula

JavaScript layout and representation of connected graphs.
https://www.graphdracula.net
MIT License
836 stars 132 forks source link

option to disable node dragging #43

Open bagnus opened 7 years ago

bagnus commented 7 years ago

I need a way to disable dragging on some nodes.

Case test: graph.addNode('Banana', { nodrag:true }); I changed the original code at bottom of drawNode():

node.shape.connections = [];
dragify(node.shape);

resulting in:

node.shape.connections = [];
if(!node.nodrag) {dragify(node.shape);}

Is there a better way to do it ?

Regards Andrea

monomon commented 6 years ago

It would be best to specify custom drag handlers, passing undefined for no drag or default. So there are three options: default drag, no drag, custom drag. imo this is most desirable for customizability. How to make the interface for this, I'm not sure. Maybe still keep the 'nodrag' option...

monomon commented 6 years ago

On a second thought, preventing the default drag and then manually hooking a custom one would be fine, too.

monomon commented 6 years ago

I have created a pull request https://github.com/strathausen/dracula/pull/47 for this. The switch is named noDefaultDrag.