OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. | 6 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. |
7 * | 7 * |
8 * @param {!Document} document Document. | 8 * @param {!Document} document Document. |
9 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 9 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
10 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 10 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // No items to the right, move the window to the left. | 182 // No items to the right, move the window to the left. |
183 this.lastVisibleIndex_--; | 183 this.lastVisibleIndex_--; |
184 if (this.firstVisibleIndex_) { | 184 if (this.firstVisibleIndex_) { |
185 this.firstVisibleIndex_--; | 185 this.firstVisibleIndex_--; |
186 var firstNode = persistentNodes[0]; | 186 var firstNode = persistentNodes[0]; |
187 if (firstNode.previousSibling) { | 187 if (firstNode.previousSibling) { |
188 // Pull back a vanishing node from the left. | 188 // Pull back a vanishing node from the left. |
189 firstNode.previousSibling.removeAttribute('vanishing'); | 189 firstNode.previousSibling.removeAttribute('vanishing'); |
190 } else { | 190 } else { |
191 // Push a new item at the left end. | 191 // Push a new item at the left end. |
192 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_); | 192 if (this.firstVisibleIndex_ < this.dataModel_.length) { |
193 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px'; | 193 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_); |
194 this.insertBefore(newThumbnail, this.firstChild); | 194 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px'; |
195 setTimeout(function() { | 195 this.insertBefore(newThumbnail, this.firstChild); |
196 newThumbnail.style.marginLeft = '0'; | 196 setTimeout(function() { |
197 }, 0); | 197 newThumbnail.style.marginLeft = '0'; |
| 198 }, 0); |
| 199 } |
198 } | 200 } |
199 } | 201 } |
200 } | 202 } |
201 | 203 |
202 var removed = false; | 204 var removed = false; |
203 for (var i = 0; i < event.removed.length; i++) { | 205 for (var i = 0; i < event.removed.length; i++) { |
204 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()]; | 206 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()]; |
205 if (removedDom) { | 207 if (removedDom) { |
206 removedDom.removeAttribute('selected'); | 208 removedDom.removeAttribute('selected'); |
207 removedDom.setAttribute('vanishing', 'smooth'); | 209 removedDom.setAttribute('vanishing', 'smooth'); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 }; | 391 }; |
390 | 392 |
391 /** | 393 /** |
392 * Set the thumbnail image. | 394 * Set the thumbnail image. |
393 * | 395 * |
394 * @param {!Element} thumbnail Thumbnail element. | 396 * @param {!Element} thumbnail Thumbnail element. |
395 * @param {!Gallery.Item} item Gallery item. | 397 * @param {!Gallery.Item} item Gallery item. |
396 * @private | 398 * @private |
397 */ | 399 */ |
398 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { | 400 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { |
| 401 if (!item.getThumbnailMetadataItem()) |
| 402 return; |
399 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { | 403 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { |
400 var loader = new ThumbnailLoader( | 404 var loader = new ThumbnailLoader( |
401 item.getEntry(), | 405 item.getEntry(), |
402 ThumbnailLoader.LoaderType.IMAGE, | 406 ThumbnailLoader.LoaderType.IMAGE, |
403 metadataList[0]); | 407 metadataList[0]); |
404 loader.load( | 408 loader.load( |
405 thumbnail.querySelector('.image-wrapper'), | 409 thumbnail.querySelector('.image-wrapper'), |
406 ThumbnailLoader.FillMode.FILL /* fill */, | 410 ThumbnailLoader.FillMode.FILL /* fill */, |
407 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); | 411 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); |
408 }); | 412 }); |
(...skipping 21 matching lines...) Expand all Loading... |
430 * @param {string} oldUrl Old url. | 434 * @param {string} oldUrl Old url. |
431 * @param {string} newUrl New url. | 435 * @param {string} newUrl New url. |
432 * @private | 436 * @private |
433 */ | 437 */ |
434 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { | 438 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { |
435 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { | 439 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { |
436 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; | 440 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; |
437 delete this.renderCache_[oldUrl]; | 441 delete this.renderCache_[oldUrl]; |
438 } | 442 } |
439 }; | 443 }; |
OLD | NEW |