How to Prevent Node Moving Outside the Lane in React Diagram?
In the Syncfusion® React Diagram you can manage the movement of nodes using Node Constraints, particularly to prevent nodes from moving outside designated lanes.
To restrict a node’s movement to only within its assigned lane, you can use the AllowMovingOutsideLane option in the node constraints. When this option is enabled, it ensures that the node can only be moved within the confines of the lane, preventing any unwanted positioning outside of it.
// set constraints as AllowMovingOutsideLane for node
constraints: NodeConstraints.Default | NodeConstraints.AllowMovingOutsideLane
set the constraints for the following Child node
children: [
{
id: 'node1',
annotations: [{ content: 'Node 1' }],
margin: { left: 60, top: 30 },
height: 40, width: 100, ports: port,
constraints: NodeConstraints.Default | NodeConstraints.AllowMovingOutsideLane
},
],
You can find a working example of this implementation in the provided sample on StackBlitz.
Click here for the sample
Conclusion
I hope you enjoyed about how to prevent node moving outside the Lane in React Diagram.
You can refer to our React 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 React 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!