How to Set the Cursor to the Diagram Node in Javascript?
This article explains 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';
}
}
Refer to the working sample for additional details and implementation:Click here for the Sample
Conclusion
We 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 learn about its other groundbreaking feature representations and documentation to quickly get started with 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, BoldDesk Support, or feedback portal. We are always happy to assist you!