event listener on mouse move code example
Example 1: javascript canvas mousemove
var canv = document.getElementById('my_canvas');
canv.addEventListener('mousemove', e => {
console.log({x:e.offsetX, y:e.offsetY, z:e})
});
var canv = document.getElementById('my_canvas');
canv.addEventListener('touchmove', e => {
ee = e.touches[0];
console.log({x:ee.clientX, y:ee.clientY, z:e})
});
Example 2: hover vanilla javascript
var target = document.querySelector(".button");
target.addEventListener("mouseover", mOver, false);
target.addEventListener("mouseout", mOut, false);
function mOver() {
target.setAttribute("style", "background-color:blue;")
}
function mOut() {
target.setAttribute("style", "background-color:green;")
}