Use performance in updateSort
This commit is contained in:
parent
8c9eab2f5e
commit
201e43f56b
|
@ -92,7 +92,6 @@ function addSortOptions() {
|
||||||
};
|
};
|
||||||
const optgroupRegex = /\{\w+\}/;
|
const optgroupRegex = /\{\w+\}/;
|
||||||
sortSelectOptions.forEach(sort => {
|
sortSelectOptions.forEach(sort => {
|
||||||
const opt = option.cloneNode();
|
|
||||||
if (optgroupRegex.test(sort)) {
|
if (optgroupRegex.test(sort)) {
|
||||||
if (container) {
|
if (container) {
|
||||||
renderBin.appendChild(container);
|
renderBin.appendChild(container);
|
||||||
|
@ -102,6 +101,7 @@ function addSortOptions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let lastTag = '';
|
let lastTag = '';
|
||||||
|
const opt = option.cloneNode();
|
||||||
opt.textContent = sort.split(sortByRegex).reduce((acc, val) => {
|
opt.textContent = sort.split(sortByRegex).reduce((acc, val) => {
|
||||||
if (tagData[val]) {
|
if (tagData[val]) {
|
||||||
lastTag = val;
|
lastTag = val;
|
||||||
|
@ -152,8 +152,21 @@ function manageSort(event) {
|
||||||
function updateSort() {
|
function updateSort() {
|
||||||
const renderBin = document.createDocumentFragment();
|
const renderBin = document.createDocumentFragment();
|
||||||
const entries = sortStyles({parser: 'entry'});
|
const entries = sortStyles({parser: 'entry'});
|
||||||
for (const entry of entries) {
|
let index = 0;
|
||||||
renderBin.appendChild(entry);
|
moveEntries();
|
||||||
|
function moveEntries() {
|
||||||
|
const t0 = performance.now();
|
||||||
|
let moved = 0;
|
||||||
|
while (
|
||||||
|
index < entries.length &&
|
||||||
|
(++moved < 10 || performance.now() - t0 < 10)
|
||||||
|
) {
|
||||||
|
renderBin.appendChild(entries[index++]);
|
||||||
|
}
|
||||||
|
if (index < entries.length) {
|
||||||
|
requestAnimationFrame(moveEntries);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
installed.appendChild(renderBin);
|
installed.appendChild(renderBin);
|
||||||
updateStripes();
|
updateStripes();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user