Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: ui/file_manager/gallery/js/slide_mode.js

Issue 792733002: Add type annotations to gallery/js/image_editor/image_view.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 // in the cache longer. 774 // in the cache longer.
775 this.imageView_.prefetch(selectedItem); 775 this.imageView_.prefetch(selectedItem);
776 } 776 }
777 777
778 function shouldPrefetch(loadType, step, sequenceLength) { 778 function shouldPrefetch(loadType, step, sequenceLength) {
779 // Never prefetch when selecting out of sequence. 779 // Never prefetch when selecting out of sequence.
780 if (Math.abs(step) != 1) 780 if (Math.abs(step) != 1)
781 return false; 781 return false;
782 782
783 // Always prefetch if the previous load was from cache. 783 // Always prefetch if the previous load was from cache.
784 if (loadType === ImageView.LOAD_TYPE_CACHED_FULL) 784 if (loadType === ImageView.LoadType.CACHED_FULL)
785 return true; 785 return true;
786 786
787 // Prefetch if we have been going in the same direction for long enough. 787 // Prefetch if we have been going in the same direction for long enough.
788 return sequenceLength >= 3; 788 return sequenceLength >= 3;
789 } 789 }
790 790
791 this.currentUniqueKey_++; 791 this.currentUniqueKey_++;
792 var selectedUniqueKey = this.currentUniqueKey_; 792 var selectedUniqueKey = this.currentUniqueKey_;
793 793
794 // Discard, since another load has been invoked after this one. 794 // Discard, since another load has been invoked after this one.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 * @param {number} delay Delay. 974 * @param {number} delay Delay.
975 * @param {*=} opt_error Error. 975 * @param {*=} opt_error Error.
976 * @private 976 * @private
977 */ 977 */
978 SlideMode.prototype.itemLoaded_ = function( 978 SlideMode.prototype.itemLoaded_ = function(
979 item, loadCallback, loadType, delay, opt_error) { 979 item, loadCallback, loadType, delay, opt_error) {
980 var entry = item.getEntry(); 980 var entry = item.getEntry();
981 var metadata = item.getMetadata(); 981 var metadata = item.getMetadata();
982 982
983 this.showSpinner_(false); 983 this.showSpinner_(false);
984 if (loadType === ImageView.LOAD_TYPE_ERROR) { 984 if (loadType === ImageView.LoadType.ERROR) {
985 // if we have a specific error, then display it 985 // if we have a specific error, then display it
986 if (opt_error) { 986 if (opt_error) {
987 this.errorBanner_.show(/** @type {string} */ (opt_error)); 987 this.errorBanner_.show(/** @type {string} */ (opt_error));
988 } else { 988 } else {
989 // otherwise try to infer general error 989 // otherwise try to infer general error
990 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); 990 this.errorBanner_.show('GALLERY_IMAGE_ERROR');
991 } 991 }
992 } else if (loadType === ImageView.LOAD_TYPE_OFFLINE) { 992 } else if (loadType === ImageView.LoadType.OFFLINE) {
993 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); 993 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE');
994 } 994 }
995 995
996 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); 996 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View'));
997 997
998 var toMillions = function(number) { 998 var toMillions = function(number) {
999 return Math.round(number / (1000 * 1000)); 999 return Math.round(number / (1000 * 1000));
1000 }; 1000 };
1001 1001
1002 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), 1002 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'),
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 var event = assertInstanceof(event, MouseEvent); 1857 var event = assertInstanceof(event, MouseEvent);
1858 var viewport = this.slideMode_.getViewport(); 1858 var viewport = this.slideMode_.getViewport();
1859 if (!this.enabled_ || !viewport.isZoomed()) 1859 if (!this.enabled_ || !viewport.isZoomed())
1860 return; 1860 return;
1861 this.stopOperation(); 1861 this.stopOperation();
1862 viewport.setOffset( 1862 viewport.setOffset(
1863 viewport.getOffsetX() + event.wheelDeltaX, 1863 viewport.getOffsetX() + event.wheelDeltaX,
1864 viewport.getOffsetY() + event.wheelDeltaY); 1864 viewport.getOffsetY() + event.wheelDeltaY);
1865 this.slideMode_.applyViewportChange(); 1865 this.slideMode_.applyViewportChange();
1866 }; 1866 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698