diff options
-rw-r--r-- | chrome/browser/resources/file_manager/css/file_manager.css | 2 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/navigation_list.js | 35 |
2 files changed, 32 insertions, 5 deletions
diff --git a/chrome/browser/resources/file_manager/css/file_manager.css b/chrome/browser/resources/file_manager/css/file_manager.css index 5b9703a..f65336d 100644 --- a/chrome/browser/resources/file_manager/css/file_manager.css +++ b/chrome/browser/resources/file_manager/css/file_manager.css @@ -256,7 +256,7 @@ div.splitter { /* TODO(yoshiki): Animation is temporary disabled for volumes. Add animation back. crbug.com/276132. */ -#volume-list li[item-type=shortcut].root-item { +#volume-list li.root-item.fadein { -webkit-animation: fadeIn 150ms ease-in-out; } diff --git a/chrome/browser/resources/file_manager/js/navigation_list.js b/chrome/browser/resources/file_manager/js/navigation_list.js index 0a9eabb..8ceb940 100644 --- a/chrome/browser/resources/file_manager/js/navigation_list.js +++ b/chrome/browser/resources/file_manager/js/navigation_list.js @@ -373,9 +373,6 @@ NavigationListItem.prototype.setModelItem = this.modelItem_ = modelItem; - this.setAttribute('item-type', - modelItem.isShortcut() ? 'shortcut' : 'volume'); - var rootType = PathUtil.getRootType(modelItem.path); this.iconDiv_.setAttribute('volume-type-icon', rootType); if (opt_deviceType) { @@ -403,6 +400,14 @@ NavigationListItem.prototype.setModelItem = }; /** + * Add/remove fade-in animation. + * @param {boolean} animation True if adding animation, false if removing. + */ +NavigationListItem.prototype.setFadeinAnimation = function(animation) { + this.classList.toggle('fadein', animation); +}; + +/** * Associate a context menu with this item. * @param {cr.ui.Menu} menu Menu this item. */ @@ -505,6 +510,23 @@ NavigationList.prototype.decorate = function(volumeManager, directoryModel) { }; /** + * This overrides cr.ui.List.measureItem(). + * In the method, a temporary element is added/removed from the list, and we + * need to omit animations for such temporary items. + * + * @param {ListItem=} opt_item The list item to be measured. + * @return {{height: number, marginTop: number, marginBottom:number, + * width: number, marginLeft: number, marginRight:number}} Size. + * @override + */ +NavigationList.prototype.measureItem = function(opt_item) { + this.measuringTemporaryItemNow_ = true; + var result = cr.ui.List.prototype.measureItem.call(this, opt_item); + this.measuringTemporaryItemNow_ = false; + return result; +}; + +/** * This overrides Node.removeChild(). * Instead of just removing the given child, this method adds a fade-out * animation and removes the child after animation completes. @@ -515,7 +537,7 @@ NavigationList.prototype.decorate = function(volumeManager, directoryModel) { NavigationList.prototype.removeChild = function(item) { // TODO(yoshiki): Animation is temporary disabled for volumes. Add animation // back. crbug.com/276132. - if (!item.modelItem.isShortcut()) { + if (!item.modelItem.isShortcut() || this.measuringTemporaryItemNow_) { Node.prototype.removeChild.call(this, item); return; } @@ -548,6 +570,11 @@ NavigationList.prototype.renderRoot_ = function(modelItem) { this.volumeManager_.getVolumeInfo(modelItem.path); item.setModelItem(modelItem, volumeInfo && volumeInfo.deviceType); + // TODO(yoshiki): Animation is temporary disabled for volumes. Add animation + // back. crbug.com/276132. + item.setFadeinAnimation(modelItem.isShortcut() && + !this.measuringTemporaryItemNow_); + var handleClick = function() { if (item.selected && modelItem.path !== this.directoryModel_.getCurrentDirPath()) { |