How to show or hide userHandles based on some constraints using Vue Diagram?
The Userhandle feature is utilized to add frequently used commands around the selector in a Vue Diagram. The user handle is visible only when a node with a value is selected. This blog will detail how to dynamically show or hide user handles for diagram objects using the selectionChange event.
To hide the user handle in a node, set the visibility of the diagram’s selection item’s user handles to false. This ensures that the user handle is not visible when a node is selected.
Here’s an example of how to set the user handle visibility to false for a node:
<ejs-diagram
style="display: block"
ref="diagramObject"
id="diagram"
:width="width"
:height="height"
:nodes="nodes"
:connectors="connectors"
:selectedItems="selectedItems"
:selectionChange="selectionChange"
></ejs-diagram>
selectionChange: (args) => {
if (args.state === 'Changed' && args.type === 'Addition') {
if (
args.newValue[0] instanceof Node &&
args.newValue[0].id === 'node1'
)
// Hides the user handle for the specified node ID
diagramInstance.selectedItems.userHandles[0].visible = false;
else if (
args.newValue[0] instanceof Connector &&
args.newValue[0].id === 'connector1'
)
// Hides the user handle for the specified connector ID
diagramInstance.selectedItems.userHandles[0].visible = false;
else {
// Sets the visible property to true
diagramInstance.selectedItems.userHandles[0].visible = true;
}
}
},
Refer to the working sample for additional details and implementation: Sample
Conclusion
We hope you enjoyed learning about how to show or hide user handles based on some constraints using Vue Diagram.
You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with 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, BoldDesk Support, or feedback portal. We are always happy to assist you!