mirror of
https://github.com/transmission/transmission
synced 2025-03-19 02:05:32 +00:00
try to avoid unnecessary reflows in two more ways: (1) use jQuery.css() to set a batch of style properties at once, instead of doing it one at a time (2) when appending rows to the torrent list, use a document fragment to batch them into a single append.
This commit is contained in:
parent
49458dcb2f
commit
0980112555
2 changed files with 11 additions and 13 deletions
|
@ -70,20 +70,16 @@ TorrentRendererHelper.createProgressbar = function(classes)
|
|||
|
||||
TorrentRendererHelper.renderProgressbar = function(controller, t, progressbar)
|
||||
{
|
||||
var e;
|
||||
var display;
|
||||
var info = TorrentRendererHelper.getProgressInfo(controller, t);
|
||||
var e, style, width, display,
|
||||
info = TorrentRendererHelper.getProgressInfo(controller, t);
|
||||
|
||||
// update the complete progressbar
|
||||
e = progressbar.complete;
|
||||
if (info.percent > 0) {
|
||||
display = 'block';
|
||||
e.style.width = '' + info.percent + '%';
|
||||
} else {
|
||||
display = 'none';
|
||||
}
|
||||
if (e.style.display !== display)
|
||||
e.style.display = display;
|
||||
style = e.style;
|
||||
width = '' + info.percent + '%';
|
||||
display = info.percent > 0 ? 'block' : 'none';
|
||||
if (style.width!==width || style.display!==display)
|
||||
$(e).css({ width: ''+info.percent+'%', display: display });
|
||||
if (e.className !== info.complete)
|
||||
e.className = info.complete;
|
||||
|
||||
|
|
|
@ -1940,7 +1940,7 @@ Transmission.prototype =
|
|||
|
||||
refilter: function(rebuildEverything)
|
||||
{
|
||||
var i, e, id, t, row, tmp, rows, clean_rows, dirty_rows,
|
||||
var i, e, id, t, row, tmp, rows, clean_rows, dirty_rows, frag,
|
||||
sort_mode = this[Prefs._SortMethod],
|
||||
sort_direction = this[Prefs._SortDirection],
|
||||
filter_mode = this[Prefs._FilterMode],
|
||||
|
@ -2008,6 +2008,7 @@ Transmission.prototype =
|
|||
rows = [];
|
||||
var ci=0, cmax=clean_rows.length;
|
||||
var di=0, dmax=dirty_rows.length;
|
||||
frag = document.createDocumentFragment();
|
||||
while (ci!=cmax || di!=dmax)
|
||||
{
|
||||
var push_clean;
|
||||
|
@ -2032,10 +2033,11 @@ Transmission.prototype =
|
|||
if (ci !== cmax)
|
||||
list.insertBefore(e, clean_rows[ci].getElement());
|
||||
else
|
||||
list.appendChild(e);
|
||||
frag.appendChild(e);
|
||||
rows.push(row);
|
||||
}
|
||||
}
|
||||
list.appendChild(frag);
|
||||
|
||||
// update our implementation fields
|
||||
this._rows = rows;
|
||||
|
|
Loading…
Add table
Reference in a new issue