| 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 * Slide mode displays a single image and has a set of controls to navigate | 6 * Slide mode displays a single image and has a set of controls to navigate |
| 7 * between the images and to edit an image. | 7 * between the images and to edit an image. |
| 8 * | 8 * |
| 9 * @param {!HTMLElement} container Main container element. | 9 * @param {!HTMLElement} container Main container element. |
| 10 * @param {!HTMLElement} content Content container element. | 10 * @param {!HTMLElement} content Content container element. |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 // in the cache longer. | 776 // in the cache longer. |
| 777 this.imageView_.prefetch(selectedItem); | 777 this.imageView_.prefetch(selectedItem); |
| 778 } | 778 } |
| 779 | 779 |
| 780 function shouldPrefetch(loadType, step, sequenceLength) { | 780 function shouldPrefetch(loadType, step, sequenceLength) { |
| 781 // Never prefetch when selecting out of sequence. | 781 // Never prefetch when selecting out of sequence. |
| 782 if (Math.abs(step) != 1) | 782 if (Math.abs(step) != 1) |
| 783 return false; | 783 return false; |
| 784 | 784 |
| 785 // Always prefetch if the previous load was from cache. | 785 // Always prefetch if the previous load was from cache. |
| 786 if (loadType === ImageView.LOAD_TYPE_CACHED_FULL) | 786 if (loadType === ImageView.LoadType.CACHED_FULL) |
| 787 return true; | 787 return true; |
| 788 | 788 |
| 789 // Prefetch if we have been going in the same direction for long enough. | 789 // Prefetch if we have been going in the same direction for long enough. |
| 790 return sequenceLength >= 3; | 790 return sequenceLength >= 3; |
| 791 } | 791 } |
| 792 | 792 |
| 793 this.currentUniqueKey_++; | 793 this.currentUniqueKey_++; |
| 794 var selectedUniqueKey = this.currentUniqueKey_; | 794 var selectedUniqueKey = this.currentUniqueKey_; |
| 795 | 795 |
| 796 // Discard, since another load has been invoked after this one. | 796 // Discard, since another load has been invoked after this one. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 * @param {number} delay Delay. | 976 * @param {number} delay Delay. |
| 977 * @param {*=} opt_error Error. | 977 * @param {*=} opt_error Error. |
| 978 * @private | 978 * @private |
| 979 */ | 979 */ |
| 980 SlideMode.prototype.itemLoaded_ = function( | 980 SlideMode.prototype.itemLoaded_ = function( |
| 981 item, loadCallback, loadType, delay, opt_error) { | 981 item, loadCallback, loadType, delay, opt_error) { |
| 982 var entry = item.getEntry(); | 982 var entry = item.getEntry(); |
| 983 var metadata = item.getMetadata(); | 983 var metadata = item.getMetadata(); |
| 984 | 984 |
| 985 this.showSpinner_(false); | 985 this.showSpinner_(false); |
| 986 if (loadType === ImageView.LOAD_TYPE_ERROR) { | 986 if (loadType === ImageView.LoadType.ERROR) { |
| 987 // if we have a specific error, then display it | 987 // if we have a specific error, then display it |
| 988 if (opt_error) { | 988 if (opt_error) { |
| 989 this.errorBanner_.show(/** @type {string} */ (opt_error)); | 989 this.errorBanner_.show(/** @type {string} */ (opt_error)); |
| 990 } else { | 990 } else { |
| 991 // otherwise try to infer general error | 991 // otherwise try to infer general error |
| 992 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); | 992 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); |
| 993 } | 993 } |
| 994 } else if (loadType === ImageView.LOAD_TYPE_OFFLINE) { | 994 } else if (loadType === ImageView.LoadType.OFFLINE) { |
| 995 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); | 995 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); |
| 996 } | 996 } |
| 997 | 997 |
| 998 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); | 998 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); |
| 999 | 999 |
| 1000 var toMillions = function(number) { | 1000 var toMillions = function(number) { |
| 1001 return Math.round(number / (1000 * 1000)); | 1001 return Math.round(number / (1000 * 1000)); |
| 1002 }; | 1002 }; |
| 1003 | 1003 |
| 1004 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), | 1004 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 var event = assertInstanceof(event, MouseEvent); | 1859 var event = assertInstanceof(event, MouseEvent); |
| 1860 var viewport = this.slideMode_.getViewport(); | 1860 var viewport = this.slideMode_.getViewport(); |
| 1861 if (!this.enabled_ || !viewport.isZoomed()) | 1861 if (!this.enabled_ || !viewport.isZoomed()) |
| 1862 return; | 1862 return; |
| 1863 this.stopOperation(); | 1863 this.stopOperation(); |
| 1864 viewport.setOffset( | 1864 viewport.setOffset( |
| 1865 viewport.getOffsetX() + event.wheelDeltaX, | 1865 viewport.getOffsetX() + event.wheelDeltaX, |
| 1866 viewport.getOffsetY() + event.wheelDeltaY); | 1866 viewport.getOffsetY() + event.wheelDeltaY); |
| 1867 this.slideMode_.applyViewportChange(); | 1867 this.slideMode_.applyViewportChange(); |
| 1868 }; | 1868 }; |
| OLD | NEW |