How to show or hide userhandles based on some constraints using Angular Diagram?
This article explains how to show or hide user handles based on certain constraints using Angular Diagram. The user handle feature is utilized to add frequently used commands around the selector in an Angular 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 items 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:
app.component.html
<ejs-diagram
#diagram
id="diagram"
width="100%"
height="645px"
(selectionChange)="selectionChange($event)"
>
</ejs-diagram>
app.component.ts
public selectionChange(args: ISelectionChangeEventArgs): void {
if (args.state === 'Changed' && args.type === 'Addition') {
if (args.newValue[0] instanceof Node && args.newValue[0].id === 'node1')
// Hides the userhandle for specified node id
this.diagram.selectedItems.userHandles[0].visible = false;
else if (
args.newValue[0] instanceof Connector &&
args.newValue[0].id === 'connector1'
)
// Hides the userhandle for specified connector id
this.diagram.selectedItems.userHandles[0].visible = false;
else {
// Sets the visible property to true
this.diagram.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 Angular Diagram.
You can refer to our Angular 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 Angular 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!