mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 02:12:00 +03:00
batch doc-list DOM inserts through a DocumentFragment
renderDocList appended each sheet's element straight to the live list, forcing a reflow per item; build them in a fragment and append once.
This commit is contained in:
parent
fc3153a7eb
commit
e774546818
1 changed files with 3 additions and 1 deletions
|
|
@ -97,6 +97,7 @@ function reorderDoc(srcId: string, targetId: string): void {
|
||||||
function renderDocList(): void {
|
function renderDocList(): void {
|
||||||
const list = $("#doc-list");
|
const list = $("#doc-list");
|
||||||
list.replaceChildren();
|
list.replaceChildren();
|
||||||
|
const frag = document.createDocumentFragment();
|
||||||
for (const doc of data.docs) {
|
for (const doc of data.docs) {
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.className = "doc-item" + (doc.id === data.activeId ? " active" : "") + (doc.pinned ? " pinned" : "");
|
el.className = "doc-item" + (doc.id === data.activeId ? " active" : "") + (doc.pinned ? " pinned" : "");
|
||||||
|
|
@ -192,8 +193,9 @@ function renderDocList(): void {
|
||||||
saveAppData(data);
|
saveAppData(data);
|
||||||
});
|
});
|
||||||
el.appendChild(del);
|
el.appendChild(del);
|
||||||
list.appendChild(el);
|
frag.appendChild(el);
|
||||||
}
|
}
|
||||||
|
list.appendChild(frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchDoc(id: string): void {
|
function switchDoc(id: string): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue