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

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

Issue 398283002: Gallery: Add the offset feature in the slide mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/viewport.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Slide mode displays a single image and has a set of controls to navigate 8 * Slide mode displays a single image and has a set of controls to navigate
9 * between the images and to edit an image. 9 * between the images and to edit an image.
10 * 10 *
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 this.dataModel_.removeEventListener('splice', this.onSpliceBound_); 327 this.dataModel_.removeEventListener('splice', this.onSpliceBound_);
328 this.dataModel_.removeEventListener('content', this.onContentBound_); 328 this.dataModel_.removeEventListener('content', this.onContentBound_);
329 this.ribbon_.disable(); 329 this.ribbon_.disable();
330 this.active_ = false; 330 this.active_ = false;
331 if (this.savedSelection_) 331 if (this.savedSelection_)
332 this.selectionModel_.selectedIndexes = this.savedSelection_; 332 this.selectionModel_.selectedIndexes = this.savedSelection_;
333 this.unloadImage_(zoomToRect); 333 this.unloadImage_(zoomToRect);
334 callback(); 334 callback();
335 }.bind(this); 335 }.bind(this);
336 336
337 this.viewport_.setZoomIndex(0); 337 this.viewport_.resetView();
338 if (this.getItemCount_() === 0) { 338 if (this.getItemCount_() === 0) {
339 this.showErrorBanner_(false); 339 this.showErrorBanner_(false);
340 commitDone(); 340 commitDone();
341 } else { 341 } else {
342 this.commitItem_(commitDone); 342 this.commitItem_(commitDone);
343 } 343 }
344 344
345 // Disable the slide-mode only buttons when leaving. 345 // Disable the slide-mode only buttons when leaving.
346 this.editButton_.setAttribute('disabled', ''); 346 this.editButton_.setAttribute('disabled', '');
347 this.printButton_.setAttribute('disabled', ''); 347 this.printButton_.setAttribute('disabled', '');
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (!this.printButton_.hasAttribute('disabled')) 839 if (!this.printButton_.hasAttribute('disabled'))
840 this.print_(); 840 this.print_();
841 break; 841 break;
842 842
843 case 'U+0045': // 'e' toggles the editor. 843 case 'U+0045': // 'e' toggles the editor.
844 if (!this.editButton_.hasAttribute('disabled')) 844 if (!this.editButton_.hasAttribute('disabled'))
845 this.toggleEditor(event); 845 this.toggleEditor(event);
846 break; 846 break;
847 847
848 case 'U+001B': // Escape 848 case 'U+001B': // Escape
849 if (!this.isEditing()) 849 if (this.isEditing()) {
850 this.toggleEditor(event);
851 } else if (this.viewport_.getZoomIndex() !== 0) {
852 this.viewport_.resetView();
853 this.imageView_.applyViewportChange();
854 } else {
850 return false; // Not handled. 855 return false; // Not handled.
851 this.toggleEditor(event); 856 }
852 break; 857 break;
853 858
854 case 'Home': 859 case 'Home':
855 this.selectFirst(); 860 this.selectFirst();
856 break; 861 break;
857 case 'End': 862 case 'End':
858 this.selectLast(); 863 this.selectLast();
859 break; 864 break;
860 case 'Up': 865 case 'Up':
861 case 'Down': 866 case 'Down':
862 case 'Left': 867 case 'Left':
863 case 'Right': 868 case 'Right':
869 if (!this.isEditing() && this.viewport_.getZoomIndex() !== 0) {
870 var delta = {
871 'Up': [0, 10], 'Down': [0, -10], 'Left': [10, 0], 'Right': [-10, 0]
mtomasz 2014/07/17 07:51:16 nit: How about moving 10 to a constant? nit: How a
hirono 2014/07/18 04:57:26 I made the offset map constant.
872 }[keyID];
873 this.viewport_.setOffset(
874 this.viewport_.getOffsetX() + delta[0],
875 this.viewport_.getOffsetY() + delta[1],
876 true);
877 this.imageView_.applyViewportChange();
878 } else {
879 this.advanceWithKeyboard(keyID);
880 }
881 break;
864 case 'MediaNextTrack': 882 case 'MediaNextTrack':
865 case 'MediaPreviousTrack': 883 case 'MediaPreviousTrack':
866 this.advanceWithKeyboard(keyID); 884 this.advanceWithKeyboard(keyID);
867 break; 885 break;
868 886
869 case 'Ctrl-U+00BB': // Ctrl+'=' zoom in. 887 case 'Ctrl-U+00BB': // Ctrl+'=' zoom in.
870 if (!this.isEditing()) { 888 if (!this.isEditing()) {
871 this.viewport_.setZoomIndex(this.viewport_.getZoomIndex() + 1); 889 this.viewport_.setZoomIndex(this.viewport_.getZoomIndex() + 1);
872 this.imageView_.applyViewportChange(); 890 this.imageView_.applyViewportChange();
873 } 891 }
874 break; 892 break;
875 893
876 case 'Ctrl-U+00BD': // Ctrl+'-' zoom out. 894 case 'Ctrl-U+00BD': // Ctrl+'-' zoom out.
877 if (!this.isEditing()) { 895 if (!this.isEditing()) {
878 this.viewport_.setZoomIndex(this.viewport_.getZoomIndex() - 1); 896 this.viewport_.setZoomIndex(this.viewport_.getZoomIndex() - 1);
879 this.imageView_.applyViewportChange(); 897 this.imageView_.applyViewportChange();
880 } 898 }
881 break; 899 break;
900
901 case 'Ctrl-U+0030': // Ctrl+'0' zoom reset.
902 if (!this.isEditing()) {
903 this.viewport_.resetView();
904 this.imageView_.applyViewportChange();
905 }
mtomasz 2014/07/17 07:51:16 nit: break; at the end for consistency?
882 } 906 }
883 907
884 return true; 908 return true;
885 }; 909 };
886 910
887 /** 911 /**
888 * Resize handler. 912 * Resize handler.
889 * @private 913 * @private
890 */ 914 */
891 SlideMode.prototype.onResize_ = function() { 915 SlideMode.prototype.onResize_ = function() {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 return this.container_.hasAttribute('slideshow'); 1063 return this.container_.hasAttribute('slideshow');
1040 }; 1064 };
1041 1065
1042 /** 1066 /**
1043 * Start the slideshow. 1067 * Start the slideshow.
1044 * @param {number=} opt_interval First interval in ms. 1068 * @param {number=} opt_interval First interval in ms.
1045 * @param {Event=} opt_event Event. 1069 * @param {Event=} opt_event Event.
1046 */ 1070 */
1047 SlideMode.prototype.startSlideshow = function(opt_interval, opt_event) { 1071 SlideMode.prototype.startSlideshow = function(opt_interval, opt_event) {
1048 // Reset zoom. 1072 // Reset zoom.
1049 this.viewport_.setZoomIndex(0); 1073 this.viewport_.resetView();
1050 this.imageView_.applyViewportChange(); 1074 this.imageView_.applyViewportChange();
1051 1075
1052 // Set the attribute early to prevent the toolbar from flashing when 1076 // Set the attribute early to prevent the toolbar from flashing when
1053 // the slideshow is being started from the mosaic view. 1077 // the slideshow is being started from the mosaic view.
1054 this.container_.setAttribute('slideshow', 'playing'); 1078 this.container_.setAttribute('slideshow', 'playing');
1055 1079
1056 if (this.active_) { 1080 if (this.active_) {
1057 this.stopEditing_(); 1081 this.stopEditing_();
1058 } else { 1082 } else {
1059 // We are in the Mosaic mode. Toggle the mode but remember to return. 1083 // We are in the Mosaic mode. Toggle the mode but remember to return.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 this.toggleMode_(this.toggleEditor.bind(this)); 1218 this.toggleMode_(this.toggleEditor.bind(this));
1195 return; 1219 return;
1196 } 1220 }
1197 1221
1198 this.stopSlideshow_(); 1222 this.stopSlideshow_();
1199 1223
1200 ImageUtil.setAttribute(this.container_, 'editing', !this.isEditing()); 1224 ImageUtil.setAttribute(this.container_, 'editing', !this.isEditing());
1201 1225
1202 if (this.isEditing()) { // isEditing has just been flipped to a new value. 1226 if (this.isEditing()) { // isEditing has just been flipped to a new value.
1203 // Reset zoom. 1227 // Reset zoom.
1204 this.viewport_.setZoomIndex(0); 1228 this.viewport_.resetView();
1205 this.imageView_.applyViewportChange(); 1229 this.imageView_.applyViewportChange();
1206 if (this.context_.readonlyDirName) { 1230 if (this.context_.readonlyDirName) {
1207 this.editor_.getPrompt().showAt( 1231 this.editor_.getPrompt().showAt(
1208 'top', 'GALLERY_READONLY_WARNING', 0, this.context_.readonlyDirName); 1232 'top', 'GALLERY_READONLY_WARNING', 0, this.context_.readonlyDirName);
1209 } 1233 }
1210 } else { 1234 } else {
1211 this.editor_.getPrompt().hide(); 1235 this.editor_.getPrompt().hide();
1212 this.editor_.leaveModeGently(); 1236 this.editor_.leaveModeGently();
1213 } 1237 }
1214 }; 1238 };
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 done = true; 1316 done = true;
1293 } 1317 }
1294 }.bind(this); 1318 }.bind(this);
1295 }; 1319 };
1296 1320
1297 /** 1321 /**
1298 * If the user touched the image and moved the finger more than SWIPE_THRESHOLD 1322 * If the user touched the image and moved the finger more than SWIPE_THRESHOLD
1299 * horizontally it's considered as a swipe gesture (change the current image). 1323 * horizontally it's considered as a swipe gesture (change the current image).
1300 */ 1324 */
1301 SwipeOverlay.SWIPE_THRESHOLD = 100; 1325 SwipeOverlay.SWIPE_THRESHOLD = 100;
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/viewport.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698