Skip to content

Commit

Permalink
fix scrolled page mouse events in Chrome 32, close #2352
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jan 15, 2014
1 parent 87757d5 commit 950034e
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/dom/DomEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,15 @@ L.DomEvent = {
},

getMousePosition: function (e, container) {
var body = document.body,
docEl = document.documentElement,
//gecko makes scrollLeft more negative as you scroll in rtl, other browsers don't
//ref: https://code.google.com/p/closure-library/source/browse/closure/goog/style/bidi.js
x = L.DomUtil.documentIsLtr() ?
(e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft : e.clientX) :
(L.Browser.gecko ? e.pageX - body.scrollLeft - docEl.scrollLeft :
e.pageX ? e.pageX - body.scrollLeft + docEl.scrollLeft : e.clientX),
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
pos = new L.Point(x, y);

if (!container) {
return pos;
return new L.Point(e.clientX, e.clientY);
}

var rect = container.getBoundingClientRect(),
left = rect.left - container.clientLeft,
top = rect.top - container.clientTop;
var rect = container.getBoundingClientRect();

return pos._subtract(new L.Point(left, top));
return new L.Point(
e.clientX - rect.left - container.clientLeft,
e.clientY - rect.top - container.clientTop);
},

getWheelDelta: function (e) {
Expand Down

0 comments on commit 950034e

Please sign in to comment.