Index: chrome/browser/resources/file_manager/js/file_manager.js |
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
index 8985495e28fa273055337f72ae87641cf5ba207c..99a04e30cf34d717c30067200d3edc1063d0c358 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -2249,12 +2249,31 @@ FileManager.prototype = { |
} |
this.previewSummary_.textContent = str('COMPUTING_SELECTION'); |
- removeChildren(this.previewThumbnails_); |
+ var thumbnails = this.document_.createDocumentFragment(); |
var fileCount = 0; |
var byteCount = 0; |
var pendingFiles = []; |
var thumbnailCount = 0; |
+ var thumbnailLoaded = -1; |
+ var forcedShowTimeout = null; |
+ var self = this; |
+ |
+ function showThumbnails() { |
+ if (forcedShowTimeout == null) |
+ return; |
+ clearTimeout(forcedShowTimeout); |
+ forcedShowTimeout = null; |
+ |
+ removeChildren(self.previewThumbnails_); |
+ self.previewThumbnails_.appendChild(thumbnails); |
+ } |
+ |
+ function onThumbnailLoaded() { |
+ thumbnailLoaded++; |
+ if (thumbnailLoaded == thumbnailCount) |
+ showThumbnails(); |
+ } |
for (var i = 0; i < selection.indexes.length; i++) { |
var entry = this.directoryModel_.fileList.item(selection.indexes[i]); |
@@ -2274,16 +2293,20 @@ FileManager.prototype = { |
if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { |
var box = this.document_.createElement('div'); |
- var imageLoadCalback = thumbnailCount == 0 && |
- this.initThumbnailZoom_.bind(this, box); |
- var thumbnail = this.renderThumbnailBox_(entry, true, imageLoadCalback); |
+ function imageLoadCalback(box) { |
+ if (thumbnailCount == 0) |
+ self.initThumbnailZoom_(box); |
+ onThumbnailLoaded(); |
+ } |
+ thumbnailCount++; |
+ var thumbnail = this.renderThumbnailBox_(entry, true, |
+ imageLoadCalback.bind(box)); |
dgozman
2012/04/17 13:33:43
imageLoadCallback.bind(null, box)
SeRya
2012/04/17 13:51:32
Done.
|
box.appendChild(thumbnail); |
box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; |
box.addEventListener('click', |
this.dispatchDefaultTask_.bind(this, selection)); |
- this.previewThumbnails_.appendChild(box); |
- thumbnailCount++; |
+ thumbnails.appendChild(box); |
} |
selection.totalCount++; |
@@ -2309,8 +2332,8 @@ FileManager.prototype = { |
// Now this.selection is complete. Update buttons. |
this.updateCommonActionButtons_(); |
this.updatePreviewPanelVisibility_(); |
- |
- var self = this; |
+ forcedShowTimeout = setTimeout(showThumbnails, 100); |
dgozman
2012/04/17 13:33:43
Cancel the previous timeout, if selection changed
SeRya
2012/04/17 13:51:32
Check the selection has not changed instead.
|
+ onThumbnailLoaded(); |
function cacheNextFile(fileEntry) { |
if (fileEntry) { |