![]() ![]() Definition and Usage The screenX property returns the horizontal screen coordinate of the mouse pointer when a mouse event is triggered. import MousePosition from ol/control/MousePosition.js import OSM from ol/source/OSM.js. The coordinates of the mouse pointer when the mouse button is clicked: let x event.screenX // Horizontal let y event.screenY // Vertical Try it Yourself More examples below. ![]() Var canvas = document.getElementById('m圜anvas') Ĭanvas. Example of a mouse position control, outside the map. Var rect = canvas.getBoundingClientRect() The MouseEvent Object The MouseEvent Object handles events that occur when the mouse interacts with the HTML document. Please move your mouse on the page to get the co-ordinates The Y coordinate of the mouse pointer in local (DOM content) coordinates. pageX Technical Details More Examples Example The coordinates of the mouse pointer while the mouse pointer moves: var x event.pageX var y event.pageY Try it Yourself » Example The differences between pageX and pageY and screenX and screenY: let pX event.pageX let pY event. To get the positions of the mouse coordinates placing on the screen, we need to use the getmousepos() which returns the positions of the mouse based on the screen with the canvas obtained from the getBoundingClientRect() method. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |