How to prevent the node interaction dynamically except selection in Vue Diagram?
This article provides a detailed explanation of how to restrict node interactions, except for selection, in the Syncfusion® Vue Diagram component. In the diagram, we create two nodes and connect them using a connector to demonstrate this functionality. The objective is to allow users to select nodes without enabling other interactions such as dragging, resizing, or rotating.
To achieve this, it is essential to configure specific constraints. By enabling the Select constraint for the nodes, you limit their interaction capabilities to selection only. Additionally, the PointerEvents property within the NodeConstraints must also be appropriately set to ensure that the nodes do not respond to other interaction types. This configuration ensures precise control over the behavior of nodes within the diagram.
node.constraints = NodeConstraints.Select | NodeConstraints.PointerEvents;
To implement this functionality, we handle the logic within the selectionChange event of the diagram component. This event allows us to monitor and control the selection process dynamically, ensuring that only the intended interaction, i.e., selection, is permitted. This approach provides a seamless and controlled user experience, particularly in scenarios where strict interaction rules are required.
selectionChange: (args) =>
{
if (diagramInstance) {
for (let i = 0; i < diagramInstance.nodes.length; i++) {
let node = diagramInstance.nodes[i];
node.constraints =
NodeConstraints.Select | NodeConstraints.PointerEvents;
diagramInstance.dataBind();
}
for (let i = 0; i < diagramInstance.connectors.length; i++) {
let connector = diagramInstance.connectors[i];
connector.constraints = ConnectorConstraints.None;
diagramInstance.dataBind();
}
}
}
Please refer to the working sample for reference.
Sample
Conclusion
I hope you enjoyed learning how to prevent the node interaction except selection of Vue Diagram.
You can refer to our Vue Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!