Reputation: 11198
For some reason, in chrome on PC (not happening on mac), when you enter full screen, the little built in chrome div pops up saying you are now in fullscreen mode and when that div dissapears, it fires a mousemove
event. Any idea why?
var idleTimer;
$videoContainer.mousemove(function()
{
if (!$jsplayer.prop('paused'))
{
if (idleTimer)
{
clearTimeout(idleTimer);
$videoControls.stop(true,true).animate({opacity:1}, animationDuration);
}
idleTimer = setTimeout(function(){
$videoControls.stop(true,true).animate({opacity:0}, animationDuration);
},3000);
}
});
It is basically causing my idle mouse function to fire when the mouse isn't actually moving. This seems to only be happening in chrome. Firefox on the PC doesn't do it, chrome on the mac doesn't do it. I am using google chrome 30.0.1599.69 m
SOLUTION
var idleTimer;
var prevX;
$videoContainer.mousemove(function(e)
{
if (!$jsplayer.prop('paused'))
{
if (idleTimer)
{
clearTimeout(idleTimer);
if (prevX != e.clientX) $videoControls.stop(true,true).animate({opacity:1});
}
prevX = e.clientX;
idleTimer = setTimeout(function(){
if (!$jsplayer.prop('paused')) $videoControls.stop(true,true).animate({opacity:0}, animationDuration);
},3000);
}
});
Upvotes: 2
Views: 2219
Reputation: 290
You can use a function like this:
(note: I use a global var window, remember change it with your global var!)
window.prev_x = null;
function mousemover(e) {
if ((window.prev_x != null) && (window.prev_x != e.x)) {
alert(e.x + ' - '+ window.prev_x);
}
window.prev_x = e.x;
};
document.addEventListener('mousemove', mousemover, false);
To avoid this event, i guess that event fire when the mouse change this window and then return to DOM of Chrome.
Upvotes: 1