Commit ae645f0e authored by yawano's avatar yawano Committed by Commit bot

Add transition animations to thumbnail updates in list view.

BUG=456016
TEST=manually tested; Edit some file in list view and see the thumbnail is updated with transition animation.

Review URL: https://codereview.chromium.org/954373003

Cr-Commit-Position: refs/heads/master@{#318679}
parent 866b00ad
...@@ -1247,6 +1247,15 @@ li[renaming=''] .badge { ...@@ -1247,6 +1247,15 @@ li[renaming=''] .badge {
} }
} }
@-webkit-keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
/* Table splitter element */ /* Table splitter element */
.table-header-splitter { .table-header-splitter {
background-image: -webkit-image-set( background-image: -webkit-image-set(
...@@ -1370,24 +1379,32 @@ body.check-select #list-container list li[selected] .detail-checkmark { ...@@ -1370,24 +1379,32 @@ body.check-select #list-container list li[selected] .detail-checkmark {
} }
#list-container list li .detail-thumbnail { #list-container list li .detail-thumbnail {
height: 28px;
overflow: hidden;
position: absolute;
width: 28px;
}
#list-container list li .detail-thumbnail > .thumbnail {
-webkit-user-drag: none; -webkit-user-drag: none;
background-color: rgb(245, 245, 245); background-color: rgb(245, 245, 245);
background-position: center; background-position: center;
background-size: cover; background-size: cover;
border-radius: 14px; border-radius: 14px;
height: 28px; height: 100%;
opacity: 0; opacity: 1;
overflow: hidden;
position: absolute; position: absolute;
transition: opacity 220ms ease; width: 100%;
width: 28px;
} }
#list-container list li .detail-thumbnail.loaded { #list-container list li .detail-thumbnail > .thumbnail.animate {
opacity: 1; -webkit-animation: fadeIn 220ms ease;
} }
body.check-select #list-container list li[selected] .detail-thumbnail.loaded { body.check-select #list-container list li[selected] .detail-thumbnail
> .thumbnail {
/* Fade out after checkmark fades in. */
-webkit-animation: fadeOut 0ms 220ms ease backwards;
opacity: 0; opacity: 0;
} }
......
...@@ -279,7 +279,7 @@ FileGrid.setThumbnailImage_ = function(box, dataUrl, shouldAnimate) { ...@@ -279,7 +279,7 @@ FileGrid.setThumbnailImage_ = function(box, dataUrl, shouldAnimate) {
thumbnail.style.backgroundImage = 'url(' + dataUrl + ')'; thumbnail.style.backgroundImage = 'url(' + dataUrl + ')';
thumbnail.addEventListener('webkitAnimationEnd', function() { thumbnail.addEventListener('webkitAnimationEnd', function() {
// Remove animation css once animation is completed in order not to animate // Remove animation css once animation is completed in order not to animate
// agein when an item is attached to the dom again. // again when an item is attached to the dom again.
thumbnail.classList.remove('animate'); thumbnail.classList.remove('animate');
for (var i = 0; i < oldThumbnails.length; i++) { for (var i = 0; i < oldThumbnails.length; i++) {
......
...@@ -394,7 +394,8 @@ FileTable.prototype.onThumbnailLoaded_ = function(event) { ...@@ -394,7 +394,8 @@ FileTable.prototype.onThumbnailLoaded_ = function(event) {
var box = listItem.querySelector('.detail-thumbnail'); var box = listItem.querySelector('.detail-thumbnail');
if (box) { if (box) {
this.setThumbnailImage_( this.setThumbnailImage_(
assertInstanceof(box, HTMLDivElement), event.dataUrl); assertInstanceof(box, HTMLDivElement), event.dataUrl,
true /* with animation */);
} }
} }
}; };
...@@ -814,7 +815,8 @@ FileTable.prototype.renderThumbnail_ = function(entry) { ...@@ -814,7 +815,8 @@ FileTable.prototype.renderThumbnail_ = function(entry) {
if (this.listThumbnailLoader_ && if (this.listThumbnailLoader_ &&
this.listThumbnailLoader_.getThumbnailFromCache(entry)) { this.listThumbnailLoader_.getThumbnailFromCache(entry)) {
this.setThumbnailImage_( this.setThumbnailImage_(
box, this.listThumbnailLoader_.getThumbnailFromCache(entry).dataUrl); box, this.listThumbnailLoader_.getThumbnailFromCache(entry).dataUrl,
false /* without animation */);
} }
return box; return box;
...@@ -824,12 +826,31 @@ FileTable.prototype.renderThumbnail_ = function(entry) { ...@@ -824,12 +826,31 @@ FileTable.prototype.renderThumbnail_ = function(entry) {
* Sets thumbnail image to the box. * Sets thumbnail image to the box.
* @param {!HTMLDivElement} box Detail thumbnail div element. * @param {!HTMLDivElement} box Detail thumbnail div element.
* @param {string} dataUrl Data url of thumbnail. * @param {string} dataUrl Data url of thumbnail.
* @param {boolean} shouldAnimate Whether the thumbnail is shown with animation
* or not.
* @private * @private
*/ */
FileTable.prototype.setThumbnailImage_ = function(box, dataUrl) { FileTable.prototype.setThumbnailImage_ = function(box, dataUrl, shouldAnimate) {
// TODO(yawano): Add transition animation for thumbnail update. var oldThumbnails = box.querySelectorAll('.thumbnail');
box.style.backgroundImage = 'url(' + dataUrl + ')';
box.classList.add('loaded'); 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);
}; };
/** /**
......
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