Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct rtl again #2136

Merged
merged 3 commits into from
Nov 3, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Delete ltr/rtl code as its not needed any more, wtf?
  • Loading branch information
danzel committed Oct 29, 2013
commit 0c7e7eb37389019e889fcfe976c72ecb8a0cea85
7 changes: 0 additions & 7 deletions spec/suites/dom/DomUtilSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ describe('DomUtil', function() {
});
});

describe('#documentIsLtr', function () {
it('returns true if doc direction is ltr', function () {
expect(L.DomUtil.documentIsLtr()).to.eql(true);
expect(L.DomUtil.documentIsLtr()).to.eql(true); // cached
});
});

describe('#getViewportOffset', function () {
it('calculates the viewport offset of an element', function () {
var div = document.createElement('div');
Expand Down
16 changes: 1 addition & 15 deletions src/dom/DomEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ L.DomEvent = {

getMousePosition: function (e, container) {

var ie7 = L.Browser.ie7,
body = document.body,
var body = document.body,
docEl = document.documentElement,
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
Expand All @@ -159,19 +158,6 @@ L.DomEvent = {
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;
}
}

return pos._subtract(new L.Point(left, top));
},

Expand Down
24 changes: 1 addition & 23 deletions src/dom/DomUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ L.DomUtil = {
el = element,
docBody = document.body,
docEl = document.documentElement,
pos,
ie7 = L.Browser.ie7;
pos;

do {
top += el.offsetTop || 0;
Expand Down Expand Up @@ -78,33 +77,12 @@ L.DomUtil = {
top -= el.scrollTop || 0;
left -= el.scrollLeft || 0;

// 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 += el.scrollWidth - el.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(el, 'overflow-y') !== 'hidden' &&
L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
left += 17;
}
}

el = el.parentNode;
} while (el);

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);
Expand Down