Commit f656ce61 authored by serya@google.com's avatar serya@google.com

Reduce blinking of icons in the preview panel.

BUG=chromium-os:29248
TEST=Manual test.

Review URL: https://chromiumcodereview.appspot.com/10107016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132572 0039d316-1c4b-4281-b951-d872f2087c98
parent ca13a448
...@@ -2249,12 +2249,34 @@ FileManager.prototype = { ...@@ -2249,12 +2249,34 @@ FileManager.prototype = {
} }
this.previewSummary_.textContent = str('COMPUTING_SELECTION'); this.previewSummary_.textContent = str('COMPUTING_SELECTION');
removeChildren(this.previewThumbnails_); var thumbnails = this.document_.createDocumentFragment();
var fileCount = 0; var fileCount = 0;
var byteCount = 0; var byteCount = 0;
var pendingFiles = []; var pendingFiles = [];
var thumbnailCount = 0; var thumbnailCount = 0;
var thumbnailLoaded = -1;
var forcedShowTimeout = null;
var self = this;
function showThumbnails() {
if (forcedShowTimeout === null)
return;
clearTimeout(forcedShowTimeout);
forcedShowTimeout = null;
// Selection could change while images are loading.
if (self.selection == selection) {
removeChildren(self.previewThumbnails_);
self.previewThumbnails_.appendChild(thumbnails);
}
}
function onThumbnailLoaded() {
thumbnailLoaded++;
if (thumbnailLoaded == thumbnailCount)
showThumbnails();
}
for (var i = 0; i < selection.indexes.length; i++) { for (var i = 0; i < selection.indexes.length; i++) {
var entry = this.directoryModel_.fileList.item(selection.indexes[i]); var entry = this.directoryModel_.fileList.item(selection.indexes[i]);
...@@ -2274,16 +2296,20 @@ FileManager.prototype = { ...@@ -2274,16 +2296,20 @@ FileManager.prototype = {
if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) {
var box = this.document_.createElement('div'); var box = this.document_.createElement('div');
var imageLoadCalback = thumbnailCount == 0 && function imageLoadCalback(index, box, img, transform) {
this.initThumbnailZoom_.bind(this, box); if (index == 0)
var thumbnail = this.renderThumbnailBox_(entry, true, imageLoadCalback); self.initThumbnailZoom_(box, img, transform);
onThumbnailLoaded();
}
var thumbnail = this.renderThumbnailBox_(entry, true,
imageLoadCalback.bind(null, thumbnailCount, box));
thumbnailCount++;
box.appendChild(thumbnail); box.appendChild(thumbnail);
box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i;
box.addEventListener('click', box.addEventListener('click',
this.dispatchDefaultTask_.bind(this, selection)); this.dispatchDefaultTask_.bind(this, selection));
this.previewThumbnails_.appendChild(box); thumbnails.appendChild(box);
thumbnailCount++;
} }
selection.totalCount++; selection.totalCount++;
...@@ -2309,8 +2335,8 @@ FileManager.prototype = { ...@@ -2309,8 +2335,8 @@ FileManager.prototype = {
// Now this.selection is complete. Update buttons. // Now this.selection is complete. Update buttons.
this.updateCommonActionButtons_(); this.updateCommonActionButtons_();
this.updatePreviewPanelVisibility_(); this.updatePreviewPanelVisibility_();
forcedShowTimeout = setTimeout(showThumbnails, 100);
var self = this; onThumbnailLoaded();
function cacheNextFile(fileEntry) { function cacheNextFile(fileEntry) {
if (fileEntry) { if (fileEntry) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment