Re-add ltr/rtl detection and make getMousePosition work correctly with rtl again when scrolled.
This commit is contained in:
parent
0c7e7eb373
commit
80c48c5da7
@ -16,6 +16,7 @@
|
||||
phantomjs = ua.indexOf('phantom') !== -1,
|
||||
android = ua.indexOf('android') !== -1,
|
||||
android23 = ua.search('android [23]') !== -1,
|
||||
gecko = ua.indexOf('gecko') !== -1,
|
||||
|
||||
mobile = typeof orientation !== undefined + '',
|
||||
msPointer = window.navigator && window.navigator.msPointerEnabled &&
|
||||
@ -72,6 +73,7 @@
|
||||
ie7: ie7,
|
||||
ielt9: ielt9,
|
||||
webkit: webkit,
|
||||
gecko: gecko && !webkit && !window.opera && !ie,
|
||||
|
||||
android: android,
|
||||
android23: android23,
|
||||
|
@ -143,10 +143,14 @@ L.DomEvent = {
|
||||
},
|
||||
|
||||
getMousePosition: function (e, container) {
|
||||
|
||||
var body = document.body,
|
||||
docEl = document.documentElement,
|
||||
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
|
||||
//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);
|
||||
|
||||
|
@ -83,6 +83,14 @@ L.DomUtil = {
|
||||
return new L.Point(left, top);
|
||||
},
|
||||
|
||||
documentIsLtr: function () {
|
||||
if (!L.DomUtil._docIsLtrCached) {
|
||||
L.DomUtil._docIsLtrCached = true;
|
||||
L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr';
|
||||
}
|
||||
return L.DomUtil._docIsLtr;
|
||||
},
|
||||
|
||||
create: function (tagName, className, container) {
|
||||
|
||||
var el = document.createElement(tagName);
|
||||
|
Loading…
Reference in New Issue
Block a user