Skip to content

Commit

Permalink
[bugfix] shouldRecycle=false breaks UI when quickly scrolling
Browse files Browse the repository at this point in the history
Should render the appendComponentPool only if ‘shouldRecycle’ is false

We can stop using this fork when the following Issue/PR is resolved:

html-next#296
html-next#299
  • Loading branch information
flexyford authored and lan0 committed Jun 8, 2020
1 parent bca121e commit c91911c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions addon/-private/data-view/radar/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class Radar {

this._componentPool = [];
this._prependComponentPool = [];
this._appendComponentPool = []; // https://github.com/html-next/vertical-collection/issues/296

// Boundaries
this._occludedContentBefore = new OccludedContent(occlusionTagName);
Expand Down Expand Up @@ -554,6 +555,8 @@ export default class Radar {
const {
virtualComponents,
_occludedContentAfter,
_appendComponentPool,
shouldRecycle,
_itemContainer
} = this;

Expand All @@ -564,6 +567,29 @@ export default class Radar {
} else {
virtualComponents.insertAt(virtualComponents.get('length') - 1, component);
component.rendered = true;

// shouldRecycle=false breaks UI when scrolling the elements fast.
// Reference https://github.com/html-next/vertical-collection/issues/296
// Components that are both new and appended still need to be rendered at the end because Glimmer.
// We have to move them _after_ they render, so we schedule that if they exist
if(!shouldRecycle) {
_appendComponentPool.unshift(component);

if (this._nextLayout === null) {
this._nextLayout = this.schedule('layout', () => {
this._nextLayout = null;

while (_appendComponentPool.length > 0) {
const component = _appendComponentPool.pop();

// Changes with each inserted component
const relativeNode = _occludedContentAfter.realUpperBound;

insertRangeBefore(this._itemContainer, relativeNode, component.realUpperBound, component.realLowerBound);
}
});
}
}
}
}

Expand Down

0 comments on commit c91911c

Please sign in to comment.