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 * The overlay displaying the image. | 6 * The overlay displaying the image. |
7 * | 7 * |
8 * @param {!HTMLElement} container The container element. | 8 * @param {!HTMLElement} container The container element. |
9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
10 * @param {!MetadataModel} metadataModel | 10 * @param {!MetadataModel} metadataModel |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 /** | 75 /** |
76 * The last load time. | 76 * The last load time. |
77 * @type {?number} | 77 * @type {?number} |
78 * @private | 78 * @private |
79 */ | 79 */ |
80 this.lastLoadTime_ = null; | 80 this.lastLoadTime_ = null; |
81 | 81 |
82 /** | 82 /** |
83 * Gallery item which is loaded. | 83 * Gallery item which is loaded. |
84 * @type {Gallery.Item} | 84 * @type {GalleryItem} |
85 * @private | 85 * @private |
86 */ | 86 */ |
87 this.contentItem_ = null; | 87 this.contentItem_ = null; |
88 | 88 |
89 /** | 89 /** |
90 * Timer to unload. | 90 * Timer to unload. |
91 * @type {?number} | 91 * @type {?number} |
92 * @private | 92 * @private |
93 */ | 93 */ |
94 this.unloadTimer_ = null; | 94 this.unloadTimer_ = null; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ImageView.LoadTarget = { | 134 ImageView.LoadTarget = { |
135 CACHED_MAIN_IMAGE: 'cachedMainImage', | 135 CACHED_MAIN_IMAGE: 'cachedMainImage', |
136 CACHED_THUMBNAIL: 'cachedThumbnail', | 136 CACHED_THUMBNAIL: 'cachedThumbnail', |
137 THUMBNAIL: 'thumbnail', | 137 THUMBNAIL: 'thumbnail', |
138 MAIN_IMAGE: 'mainImage' | 138 MAIN_IMAGE: 'mainImage' |
139 }; | 139 }; |
140 | 140 |
141 /** | 141 /** |
142 * Obtains prefered load type from GalleryItem. | 142 * Obtains prefered load type from GalleryItem. |
143 * | 143 * |
144 * @param {!Gallery.Item} item | 144 * @param {!GalleryItem} item |
145 * @param {!ImageView.Effect} effect | 145 * @param {!ImageView.Effect} effect |
146 * @return {ImageView.LoadTarget} Load target. | 146 * @return {ImageView.LoadTarget} Load target. |
147 */ | 147 */ |
148 ImageView.getLoadTarget = function(item, effect) { | 148 ImageView.getLoadTarget = function(item, effect) { |
149 if (item.contentImage) | 149 if (item.contentImage) |
150 return ImageView.LoadTarget.CACHED_MAIN_IMAGE; | 150 return ImageView.LoadTarget.CACHED_MAIN_IMAGE; |
151 if (item.screenImage) | 151 if (item.screenImage) |
152 return ImageView.LoadTarget.CACHED_THUMBNAIL; | 152 return ImageView.LoadTarget.CACHED_THUMBNAIL; |
153 | 153 |
154 // Only show thumbnails if there is no effect or the effect is Slide. | 154 // Only show thumbnails if there is no effect or the effect is Slide. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 ImageView.prototype.cancelLoad = function() { | 358 ImageView.prototype.cancelLoad = function() { |
359 this.imageLoader_.cancel(); | 359 this.imageLoader_.cancel(); |
360 }; | 360 }; |
361 | 361 |
362 /** | 362 /** |
363 * Loads and display a new image. | 363 * Loads and display a new image. |
364 * | 364 * |
365 * Loads the thumbnail first, then replaces it with the main image. | 365 * Loads the thumbnail first, then replaces it with the main image. |
366 * Takes into account the image orientation encoded in the metadata. | 366 * Takes into account the image orientation encoded in the metadata. |
367 * | 367 * |
368 * @param {!Gallery.Item} item Gallery item to be loaded. | 368 * @param {!GalleryItem} item Gallery item to be loaded. |
369 * @param {!ImageView.Effect} effect Transition effect object. | 369 * @param {!ImageView.Effect} effect Transition effect object. |
370 * @param {function()} displayCallback Called when the image is displayed | 370 * @param {function()} displayCallback Called when the image is displayed |
371 * (possibly as a preview). | 371 * (possibly as a preview). |
372 * @param {function(!ImageView.LoadType, number, *=)} loadCallback Called when | 372 * @param {function(!ImageView.LoadType, number, *=)} loadCallback Called when |
373 * the image is fully loaded. The first parameter is the load type. | 373 * the image is fully loaded. The first parameter is the load type. |
374 */ | 374 */ |
375 ImageView.prototype.load = | 375 ImageView.prototype.load = |
376 function(item, effect, displayCallback, loadCallback) { | 376 function(item, effect, displayCallback, loadCallback) { |
377 var entry = item.getEntry(); | 377 var entry = item.getEntry(); |
378 | 378 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (loadType === ImageView.LoadType.ERROR && | 511 if (loadType === ImageView.LoadType.ERROR && |
512 !navigator.onLine && !item.getMetadataItem().present) { | 512 !navigator.onLine && !item.getMetadataItem().present) { |
513 loadType = ImageView.LoadType.OFFLINE; | 513 loadType = ImageView.LoadType.OFFLINE; |
514 } | 514 } |
515 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); | 515 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); |
516 } | 516 } |
517 }; | 517 }; |
518 | 518 |
519 /** | 519 /** |
520 * Prefetches an image. | 520 * Prefetches an image. |
521 * @param {!Gallery.Item} item The image item. | 521 * @param {!GalleryItem} item The image item. |
522 * @param {number=} opt_delay Image load delay in ms. | 522 * @param {number=} opt_delay Image load delay in ms. |
523 */ | 523 */ |
524 ImageView.prototype.prefetch = function(item, opt_delay) { | 524 ImageView.prototype.prefetch = function(item, opt_delay) { |
525 if (item.contentImage || this.prefetchLoader_.isLoading(item.getEntry())) | 525 if (item.contentImage || this.prefetchLoader_.isLoading(item.getEntry())) |
526 return; | 526 return; |
527 this.prefetchLoader_.load(item, function(canvas) { | 527 this.prefetchLoader_.load(item, function(canvas) { |
528 if (canvas.width && canvas.height && !item.contentImage) | 528 if (canvas.width && canvas.height && !item.contentImage) |
529 item.contentImage = canvas; | 529 item.contentImage = canvas; |
530 }, opt_delay); | 530 }, opt_delay); |
531 }; | 531 }; |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1013 |
1014 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 1014 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
1015 | 1015 |
1016 /** | 1016 /** |
1017 * @override | 1017 * @override |
1018 */ | 1018 */ |
1019 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 1019 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
1020 return viewport.getRotatingTransformation( | 1020 return viewport.getRotatingTransformation( |
1021 element.width, element.height, this.orientation_ ? -1 : 1); | 1021 element.width, element.height, this.orientation_ ? -1 : 1); |
1022 }; | 1022 }; |
OLD | NEW |