+ 2
Can someone please explain how to get mousecoordinates in javascript without jQuery
I want to make particles/objects that follows your mouse
3 Answers
+ 12
https://code.sololearn.com/WnmDepNix3Qh/?ref=app
(see the script ^_^)
+ 3
Capture mouse move event of the body tag, and you'll get the mouse position coordinates into the event object passed to the callback function:
window.onload = function() {
document.body.onmousemove = function(evt) {
var x = evt.clientX;
var y = evt.clientY;
console.log(x,y);
}
}
For finger/gesture handling, you need to look at 'touch' events, which provides similar event and properties to read the coordinates of finger(s)...
+ 1
Thanks visph