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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/file_table.js

Issue 954373003: Add transition animations to thumbnail updates in list view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix to pass presubmit. Created 5 years, 10 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 | « ui/file_manager/file_manager/foreground/js/ui/file_grid.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/file_table.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_table.js b/ui/file_manager/file_manager/foreground/js/ui/file_table.js
index 7d62b53bb11136a65ffa37ee0587f40689b9459d..5bd55474301d5e2cdbdf87fd0a8baf0ee992cc11 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/file_table.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/file_table.js
@@ -394,7 +394,8 @@ FileTable.prototype.onThumbnailLoaded_ = function(event) {
var box = listItem.querySelector('.detail-thumbnail');
if (box) {
this.setThumbnailImage_(
- assertInstanceof(box, HTMLDivElement), event.dataUrl);
+ assertInstanceof(box, HTMLDivElement), event.dataUrl,
+ true /* with animation */);
}
}
};
@@ -814,7 +815,8 @@ FileTable.prototype.renderThumbnail_ = function(entry) {
if (this.listThumbnailLoader_ &&
this.listThumbnailLoader_.getThumbnailFromCache(entry)) {
this.setThumbnailImage_(
- box, this.listThumbnailLoader_.getThumbnailFromCache(entry).dataUrl);
+ box, this.listThumbnailLoader_.getThumbnailFromCache(entry).dataUrl,
+ false /* without animation */);
}
return box;
@@ -824,12 +826,31 @@ FileTable.prototype.renderThumbnail_ = function(entry) {
* Sets thumbnail image to the box.
* @param {!HTMLDivElement} box Detail thumbnail div element.
* @param {string} dataUrl Data url of thumbnail.
+ * @param {boolean} shouldAnimate Whether the thumbnail is shown with animation
+ * or not.
* @private
*/
-FileTable.prototype.setThumbnailImage_ = function(box, dataUrl) {
- // TODO(yawano): Add transition animation for thumbnail update.
- box.style.backgroundImage = 'url(' + dataUrl + ')';
- box.classList.add('loaded');
+FileTable.prototype.setThumbnailImage_ = function(box, dataUrl, shouldAnimate) {
+ var oldThumbnails = box.querySelectorAll('.thumbnail');
+
+ var thumbnail = box.ownerDocument.createElement('div');
+ thumbnail.classList.add('thumbnail');
+ thumbnail.style.backgroundImage = 'url(' + dataUrl + ')';
+ thumbnail.addEventListener('webkitAnimationEnd', function() {
+ // Remove animation css once animation is completed in order not to animate
+ // again when an item is attached to the dom again.
+ thumbnail.classList.remove('animate');
+
+ for (var i = 0; i < oldThumbnails.length; i++) {
+ if (box.contains(oldThumbnails[i]))
+ box.removeChild(oldThumbnails[i]);
+ }
+ });
+
+ if (shouldAnimate)
+ thumbnail.classList.add('animate');
+
+ box.appendChild(thumbnail);
};
/**
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/file_grid.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698