JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Chrome handles mousemove differently</h1>
<p>Keep the mouse on the element without moving it.<br/>
You'd expect no mousemove events to be triggered as the element moves in and out of view, since you are not moving the mouse.</p>
<p><i>This isn't the case in Chrome (37.0.2062.124 m)</i></p>
<div id='element'></div>
<p>mousemoves: <span id='times'>0</span></p>
CSS
body { font: 16px/28px Georgia, Times, "Times New Roman", serif; }
#element {
float: left;
clear: both;
width: 200px;
height: 200px;
background-color: #fc755a;
margin: 0 15px 15px 0;
}
#times { font-weight: bold; }
p { float: left; clear: both; }
JavaScript
var moves = 0;
// vanilla js, to make sure this isn't jQuery
addEvent(document.getElementById('element'), 'mousemove', function() {
document.getElementById('times').innerHTML = moves++;
});
// some helpers
function addEvent(elem, evnt, func) {
if (elem.addEventListener) {
elem.addEventListener(evnt, func, false);
} else if (elem.attachEvent) {
elem.attachEvent("on" + evnt, func);
} else {
elem[evnt] = func;
}
}
function fadeIn(cb) { $('#element').fadeIn(cb); }
function fadeOut(cb) { $('#element').fadeOut(cb); }
function inout() { fadeIn(function() { fadeOut(function() { inout(); }); }); }
inout();