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

Update: Change VirtualScroller.renderItems strategy #900

Merged
merged 3 commits into from
Jan 24, 2019

Conversation

ConradJChan
Copy link
Contributor

Changed the strategy from re-creating the ol on each render, to manipulating the individual li (creating new ones and deleting the old ones outside the "window" into the list).

This is because Safari wasn't smart about the cloned elements in the previous strategy and would cause a flicker of the thumbnails on each renderItems call

@boxcla
Copy link

boxcla commented Jan 23, 2019

Verified that @ConradJChan has signed the CLA. Thanks for the pull request!

* @param {number} start - start index
* @param {number} end - end index
* @param {number} [end] - end index
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should [end] be in brackets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to because if not provided (which is how I call it https://github.com/box/box-content-preview/pull/900/files#diff-ae1d3917492ce0b7a65c4b31408eb5deR282) it will just delete to the end of the listEl's children

@@ -254,7 +254,7 @@ class VirtualScroller {
}

// Create a new list element to be swapped out for the existing one
const newListEl = this.createListElement();
const newListEl = document.createDocumentFragment();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming here seems a little confusing, since later we append this to this.listEl.

newListEl.appendChild(newEl);
}
const listItems = Array.prototype.slice.call(listEl.children, start, end);
listItems.forEach((listItem) => listEl.removeChild(listItem));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we incur a performance penalty here, since this.listEl is currently mounted? Each removeChild call will force a reflow, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so because all the li are absolutely positioned

@@ -254,7 +254,7 @@ class VirtualScroller {
}

// Create a new list element to be swapped out for the existing one
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still relevant?

@ConradJChan ConradJChan merged commit 85aabdb into box:thumbnails-sidebar Jan 24, 2019
@ConradJChan ConradJChan deleted the virtual-scroll-update branch January 24, 2019 21:19
ConradJChan pushed a commit to ConradJChan/box-content-preview that referenced this pull request Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants