How to Set the Cursor to the Diagram Node in Javascript?
To improve user experience in the Syncfusion® JavaScript Diagram by dynamically changing the cursor style based on user interactions, specifically changing to a pointer when hovering over nodes and to a grabbing hand when hovering over empty spaces.
onmousemove event changes the cursor style based on the mouse position.
If the mouse is over a node, the cursor changes to a pointer .
If the mouse is over the empty space of the diagram, the cursor changes to grabbing, indicating that the diagram can be panned.
document.getElementById("diagram").onmousemove = function onMouseMove(args) {
var diagramCanvas = document.getElementById(diagram.element.id + 'content');
if ((args.target).id != 'diagram_diagramLayer_svg') {
diagramCanvas.style.cursor = 'pointer';
}
else {
diagramCanvas.style.cursor = 'grabbing';
}
}
Sample:
Click here for the Sample
Conclusion
I hope you enjoyed learning how to set the cursor to the Diagram node in Javascript.
You can refer to our JavaScript 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 JavaScript 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!