Skip to content

Commit

Permalink
fix: account both edges in endSearchFunction fn (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
re3lex authored May 12, 2020
1 parent 0d1252b commit f75c2d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/timeline/component/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,11 @@ class Group {
};

// this function is used to do the binary search for items having start and end dates (range).
const endSearchFunction = value => {
if (value < lowerBound) {return -1;}
else {return 0;}
const endSearchFunction = data => {
const {start, end} = data;
if (end < lowerBound) {return -1;}
else if (start <= upperBound) {return 0;}
else {return 1;}
}

// first check if the items that were in view previously are still in view.
Expand Down Expand Up @@ -955,7 +957,7 @@ class Group {
}
else {
// we do a binary search for the items that have defined end times.
const initialPosByEnd = util.binarySearchCustom(orderedItems.byEnd, endSearchFunction, 'data','end');
const initialPosByEnd = util.binarySearchCustom(orderedItems.byEnd, endSearchFunction, 'data');

// trace the visible items from the inital start pos both ways until an invisible item is found, we only look at the end values.
this._traceVisible(initialPosByEnd, orderedItems.byEnd, visibleItems, visibleItemsLookup, item => item.data.end < lowerBound || item.data.start > upperBound);
Expand Down

0 comments on commit f75c2d3

Please sign in to comment.