How to Prevent Node Rotation in Angular Diagram?
In this article, you can learn about how to prevent node rotation in Angular Diagram. In the Syncfusion® Angular Diagram, we have the flexibility to enable or disable specific behaviors of nodes through the use of NodeConstraints.
To prevent the rotation of a node in a diagram, we can use the Rotate NodeConstraint and disable it using the Bitwise ‘&~’ (XOR) operator.
//Set the constraints for node as Rotate and disable it
constraints: NodeConstraints.Default & ~NodeConstraints.Rotate,
Below is a code example demonstrating how to prevent rotation in node :
import {
DiagramModule,
DiagramComponent,
NodeModel,
NodeConstraints,
} from '@syncfusion/ej2-angular-diagrams';
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
@Component({
imports: [DiagramModule],
providers: [],
standalone: true,
selector: 'app-container',
template: `<ejs-diagram #diagram id="diagram" width="100%" height="580px" [getNodeDefaults] ='getNodeDefaults'>
<e-nodes>
<e-node id='node1' [offsetX]=250 [offsetY]=250 [constraints]='nodeConstraints'></e-node>
</e-nodes>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None,
})
export class AppComponent {
@ViewChild('diagram')
public diagram?: DiagramComponent;
public nodeConstraints?: NodeConstraints;
ngOnInit(): void {
this.nodeConstraints = NodeConstraints.Default & ~NodeConstraints.Rotate;
}
public getNodeDefaults(node: NodeModel): NodeModel {
node.height = 100;
node.width = 100;
return node;
}
}
Sample : Prevent Node Rotation
Conclusion
We hope you enjoyed learning how to prevent node rotation in 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!