- x = e.pageX ? e.pageX : e.clientX + body.scrollLeft + docEl.scrollLeft,
- y = e.pageY ? e.pageY : e.clientY + body.scrollTop + docEl.scrollTop,
- pos = new L.Point(x, y);
+ x = 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),
+ rect = container.getBoundingClientRect(),
+ left = rect.left - container.clientLeft,
+ top = rect.top - container.clientTop;
+
+ // webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
+ // https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
+ if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
+ left += container.scrollWidth - container.clientWidth;
+
+ // ie7 shows the scrollbar by default and provides clientWidth counting it, so we
+ // need to add it back in if it is visible; scrollbar is on the left as we are RTL
+ if (ie7 && L.DomUtil.getStyle(container, 'overflow-y') !== 'hidden' &&
+ L.DomUtil.getStyle(container, 'overflow') !== 'hidden') {
+ left += 17;
+ }
+ }