Skip to content

Commit bd311f0

Browse files
committed
fix for wrong mousemove event on Chrome browser
1 parent aca237f commit bd311f0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

jquery.jplayer/jquery.jplayer.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@
685685
// domNode: undefined
686686
// htmlDlyCmdId: undefined
687687
// autohideId: undefined
688+
// lastMousePosition: undefined
688689
// cmdsIgnored
689690
},
690691
solution: { // Static Object: Defines the solutions built in jPlayer.
@@ -2501,13 +2502,30 @@
25012502
event = "mousemove.jPlayer",
25022503
namespace = ".jPlayerAutohide",
25032504
eventType = event + namespace,
2504-
handler = function() {
2505+
handler = function(sourceEvent) {
2506+
var mouseMoved = false;
2507+
if (self.internal.lastMousePosition != undefined) {
2508+
//get the change from last position to this position
2509+
var deltaX = self.internal.lastMousePosition.x - sourceEvent.clientX,
2510+
deltaY = self.internal.lastMousePosition.y - sourceEvent.clientY;
2511+
mouseMoved = (Math.abs(deltaX)>0) || (Math.abs(deltaY)>0);
2512+
} else {
2513+
mouseMoved = true;
2514+
}
2515+
// store current position for next method execution
2516+
self.internal.lastMousePosition = {
2517+
x : sourceEvent.clientX,
2518+
y : sourceEvent.clientY
2519+
};
2520+
// if mouse has been actually moved, do the gui fadeIn/fadeOut
2521+
if (mouseMoved) {
25052522
self.css.jq.gui.fadeIn(self.options.autohide.fadeIn, function() {
25062523
clearTimeout(self.internal.autohideId);
25072524
self.internal.autohideId = setTimeout( function() {
25082525
self.css.jq.gui.fadeOut(self.options.autohide.fadeOut);
25092526
}, self.options.autohide.hold);
25102527
});
2528+
}
25112529
};
25122530

25132531
if(this.css.jq.gui.length) {
@@ -2518,6 +2536,8 @@
25182536

25192537
// Removes the fadeOut operation from the fadeIn callback.
25202538
clearTimeout(this.internal.autohideId);
2539+
// undefine lastMousePosition
2540+
delete this.internal.lastMousePosition;
25212541

25222542
this.element.unbind(namespace);
25232543
this.css.jq.gui.unbind(namespace);

0 commit comments

Comments
 (0)