From f75c2d3d501605f2369d30139b6319fb55ffb995 Mon Sep 17 00:00:00 2001 From: re3lex Date: Tue, 12 May 2020 23:45:53 +0400 Subject: [PATCH] fix: account both edges in endSearchFunction fn (#469) --- lib/timeline/component/Group.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index e8cc1e172f..d2da5a4c37 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -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. @@ -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);