Cache remembering if the document is Left to right. Do it at the document level rather than the element level as it isn't likely to change.

This commit is contained in:
danzel 2012-10-29 10:48:01 +13:00
parent c649a4fd92
commit 126a316916

View File

@ -56,7 +56,7 @@ L.DomUtil = {
//See https://developer.mozilla.org/en-US/docs/DOM/element.scrollLeft
// http://www.nczonline.net/blog/2010/08/03/working-with-bidirectional-bidi-text-and-rtl-languages-on-the-web/
if (L.DomUtil.getStyle(el, 'direction') == "ltr") {
if (L.DomUtil.documentIsLtr()) {
left -= el.scrollLeft || 0;
} else {
left -= (el.scrollLeft || 0) - el.scrollWidth + el.clientWidth;
@ -68,6 +68,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);