I am trying to call some functions whenever the mouse is moved wherever it is located on the browser window. Currently, I am using:
$('html').live('mousemove', function(e) { ... }
which does not seem to work once the page scrolls down.
Is there a way to bind the mousemove event to the entire window?
$(window).live('mousemove', function(e) { ... }
results in nothing.
—
EDIT:
My code for the mouse function is as follows:
function mouseEvents() {
// set up mouse movement
$(window).on('mousemove', function(e) {
if (window.imgLoaded) {
var x = e.pageX/$(window).width()*504;
var y = e.pageY/$(window).height()*504;
console.log(y);
drawKaleidoscope(window.ctx, window.img, x / 2, y / 2);
}
});
}
$(document).bind("mousemove", function(e) { ... } )To trigger on scrolls as well (moving mousewheel doesn’t trigger mousemove)$(document).bind("mousemove mousewheel DOMMouseScroll", function(e) { ... } )whereDOMMouseScrollis firefox specific event for mousewheel.