Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10107016: Reduce blinking of icons in the preview panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698