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

fix(item-update): visibility of range spanning items not always correct #1846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
27 changes: 4 additions & 23 deletions lib/timeline/component/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ class Group {
*/
_resetSubgroups() {
for (const subgroup in this.subgroups) {
if (this.subgroups.hasOwnProperty(subgroup)) {
if (Object.prototype.hasOwnProperty.call(this.subgroups, subgroup)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to the fix but the pre-commit-hook did not let me commit without fixing it because it lints the whole file instead of only the changes.

this.subgroups[subgroup].visible = false;
this.subgroups[subgroup].height = 0;
}
Expand Down Expand Up @@ -924,14 +924,6 @@ class Group {
else {return 1;}
};

// this function is used to do the binary search for items having start and end dates (range).
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.
// IMPORTANT: this handles the case for the items with startdate before the window and enddate after the window!
// also cleans up invisible items.
Expand All @@ -947,20 +939,9 @@ class Group {
// trace the visible items from the inital start pos both ways until an invisible item is found, we only look at the start values.
this._traceVisible(initialPosByStart, orderedItems.byStart, visibleItems, visibleItemsLookup, item => item.data.start < lowerBound || item.data.start > upperBound);

// if the window has changed programmatically without overlapping the old window, the ranged items with start < lowerBound and end > upperbound are not shown.
// We therefore have to brute force check all items in the byEnd list
if (this.checkRangedItems == true) {
this.checkRangedItems = false;
for (let i = 0; i < orderedItems.byEnd.length; i++) {
this._checkIfVisibleWithReference(orderedItems.byEnd[i], visibleItems, visibleItemsLookup, range);
}
}
else {
// we do a binary search for the items that have defined end times.
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);
// check every item with end date if is visible. Binary search would be the most efficient, but it would leave out items that start before the range and end after the range.
for (let i = 0; i < orderedItems.byEnd.length; i++) {
this._checkIfVisibleWithReference(orderedItems.byEnd[i], visibleItems, visibleItemsLookup, range);
}

const redrawQueue = {};
Expand Down