Batch DOM updates to improve speed with less reflows.
This commit is contained in:
parent
c58cea1174
commit
34f10e1b02
|
@ -452,6 +452,7 @@ function deleteDownloadTemplates(top_elem, data) {
|
||||||
}
|
}
|
||||||
function refreshDownloadTemplates(top_elem, data) {
|
function refreshDownloadTemplates(top_elem, data) {
|
||||||
var down_template = $('#download_' + top_elem + '_template').text();
|
var down_template = $('#download_' + top_elem + '_template').text();
|
||||||
|
var new_items = [];
|
||||||
deleteDownloadTemplates('#' + top_elem + '_downloads', data);
|
deleteDownloadTemplates('#' + top_elem + '_downloads', data);
|
||||||
for(var i = 0; i < data.length; i++) {
|
for(var i = 0; i < data.length; i++) {
|
||||||
var ctx = getTemplateCtx(data[i]);
|
var ctx = getTemplateCtx(data[i]);
|
||||||
|
@ -460,11 +461,13 @@ function refreshDownloadTemplates(top_elem, data) {
|
||||||
updateDownloadTemplates(elem, ctx);
|
updateDownloadTemplates(elem, ctx);
|
||||||
} else {
|
} else {
|
||||||
var item = Mustache.render(down_template, ctx);
|
var item = Mustache.render(down_template, ctx);
|
||||||
$('#' + top_elem + '_downloads').prepend(item);
|
new_items.unshift(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (new_items.length > 0) {
|
||||||
|
$('#' + top_elem + '_downloads').prepend(new_items);
|
||||||
|
}
|
||||||
$('#' + top_elem + '_downloads').children('.hero-unit').remove();
|
$('#' + top_elem + '_downloads').children('.hero-unit').remove();
|
||||||
|
|
||||||
}
|
}
|
||||||
function updateGraph(gid) {
|
function updateGraph(gid) {
|
||||||
var elem = $('[data-gid=' + gid + ']');
|
var elem = $('[data-gid=' + gid + ']');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user