Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #225 from killkeeper/master
Browse files Browse the repository at this point in the history
Fixed a bug in mouseOffset() with Firefox, which lacks event.offsetX/Y properties
  • Loading branch information
wch committed Aug 22, 2014
2 parents 358acdc + 83cb854 commit 20590b1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions inst/www/ggvis/js/ggvis.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,21 @@ ggvis = (function(_) {

// Internal functions --------------------------------------------
function mouseOffset(e) {
return {
x: e.offsetX,
y: e.offsetY
};
// A workaround for Firefox, which doesn't provide offsetX/Y
// for mouse event.
if (typeof(e.offsetX) === "undefined") {
var offset = $(e.currentTarget).offset();
return {
x: e.pageX - offset.left,
y: e.pageY - offset.top
};
}
else {
return {
x: e.offsetX,
y: e.offsetY
};
}
}

return brush;
Expand Down

0 comments on commit 20590b1

Please sign in to comment.