simpler and faster mouse pos; remove DomUtil.documentIsLtr

This commit is contained in:
Vladimir Agafonkin 2013-12-24 18:46:05 +02:00
parent 9eaaf096c1
commit 8764063c46
2 changed files with 5 additions and 22 deletions

View File

@ -141,27 +141,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 = e.pageX ? e.pageX - body.scrollLeft -
docEl.scrollLeft * (L.DomUtil.documentIsLtr() || L.Browser.gecko ? 1 : -1) : 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) {

View File

@ -19,11 +19,6 @@ L.DomUtil = {
return value === 'auto' ? null : value;
},
documentIsLtr: function () {
L.DomUtil._docIsLtr = L.DomUtil._docIsLtr || L.DomUtil.getStyle(document.body, 'direction') === 'ltr';
return L.DomUtil._docIsLtr;
},
create: function (tagName, className, container) {
var el = document.createElement(tagName);