How to restrict the elements/ objects in positive side of the React Diagram?
This article explains how to restrict the elements/objects to the positive side of the React Diagram. In Syncfusion® React Diagram, it is possible to restrict the diagram elements to the positive side of the diagram by using the boundaryConstraints property of pageSettings.
By default, the boundaryConstraints property is set to “Infinity,” allowing dragging anywhere in the diagram. To restrict the diagram element to the positive side, set the boundaryConstraints to “Page” in the pageSettings, and ensure to set the width and height of the pageSettings accordingly. This ensures that the diagram elements are draggable only within the specified bounds based on the defined width and height of the diagram’s pageSettings.
Boundary constraints as Page:
pageSettings={{
width: 500,
height: 500,
boundaryConstraints: 'Page',
showPageBreaks: true,
}}
Here, the diagram nodes are only draggable within the positive side of the diagram’s page bounds, which are set to a width of 500 and a height of 500, and we cannot drag the diagram object beyond these page bounds.
Boundary constraints as Diagram:
To confine the diagram element to the positive side within the viewport area, set the boundaryConstraints to “Diagram” in the pageSettings. In this mode, the diagram elements are draggable only within the diagram bounds.
pageSettings={{
width: 500,
height: 500,
boundaryConstraints: 'Diagram',
showPageBreaks: true,
}}
In this setup, the diagram nodes can only be dragged within the positive side of the diagram’s boundaries, regardless of the page’s width and height.
Sample:
Refer to the working sample for additional details and implementation: Sample
Conclusion
We hope you enjoyed learning about how to restrict the elements/objects on the positive side of the React Diagram.
You can refer to our React Diagram feature tour page to know about its other groundbreaking feature representations and documentations. You can also explore our React Diagram example to understand how to present 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 React Spreadsheet and other components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!