Skip to content

Commit

Permalink
Fix getVisibleElements helper in RTL-locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed committed Oct 9, 2020
1 parent 88f72d6 commit e1cadbe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,13 @@ function getVisibleElements(
element.offsetTop + element.clientTop + element.clientHeight;
return elementBottom > top;
}
function isElementRightAfterViewLeft(view) {
function isElementNextAfterViewHorizontally(view) {
const element = view.div;
const elementLeft =
element.offsetLeft + element.clientLeft;
const elementRight =
element.offsetLeft + element.clientLeft + element.clientWidth;
return elementRight > left;
elementLeft + element.clientWidth;
return document.dir === "rtl" ? elementLeft < right : elementRight > left;
}

const visible = [],
Expand All @@ -479,7 +481,7 @@ function getVisibleElements(
? 0
: binarySearchFirstItem(
views,
horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop
horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop
);

// Please note the return value of the `binarySearchFirstItem` function when
Expand Down

0 comments on commit e1cadbe

Please sign in to comment.