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

Side by Side Diff: chrome/browser/resources/file_manager/js/photo/gallery.js

Issue 10919292: Photo Editor: better mode transitions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 document.addEventListener('DOMContentLoaded', function() { 5 document.addEventListener('DOMContentLoaded', function() {
6 if (!location.hash) 6 if (!location.hash)
7 return; 7 return;
8 8
9 var pageState; 9 var pageState;
10 if (location.search) { 10 if (location.search) {
11 try { 11 try {
12 pageState = JSON.parse(location.search.substr(1)); 12 pageState = JSON.parse(decodeURIComponent(location.search.substr(1)));
13 } catch (ignore) {} 13 } catch (ignore) {}
14 } 14 }
15 Gallery.openStandalone(decodeURI(location.hash.substr(1)), pageState); 15 Gallery.openStandalone(decodeURI(location.hash.substr(1)), pageState);
16 }); 16 });
17 17
18 /** 18 /**
19 * Gallery for viewing and editing image files. 19 * Gallery for viewing and editing image files.
20 * 20 *
21 * @param {Object} context Object containing the following: 21 * @param {Object} context Object containing the following:
22 * {function(string)} onNameChange Called every time a selected 22 * {function(string)} onNameChange Called every time a selected
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 var selectedIndex = urls.indexOf(selectedUrls[i]); 259 var selectedIndex = urls.indexOf(selectedUrls[i]);
260 if (selectedIndex >= 0) 260 if (selectedIndex >= 0)
261 this.selectionModel_.setIndexSelected(selectedIndex, true); 261 this.selectionModel_.setIndexSelected(selectedIndex, true);
262 else 262 else
263 console.error('Cannot select ' + selectedUrls[i]); 263 console.error('Cannot select ' + selectedUrls[i]);
264 } 264 }
265 265
266 if (this.selectionModel_.selectedIndexes.length == 0) 266 if (this.selectionModel_.selectedIndexes.length == 0)
267 this.onSelection_(); 267 this.onSelection_();
268 268
269 var mosaic = this.mosaicMode_.getMosaic();
269 if (selectedUrls.length != 1 || 270 if (selectedUrls.length != 1 ||
270 (this.context_.pageState && 271 (this.context_.pageState &&
271 this.context_.pageState.gallery == 'mosaic')) { 272 this.context_.pageState.gallery == 'mosaic')) {
272 this.setCurrentMode_(this.mosaicMode_); 273 this.setCurrentMode_(this.mosaicMode_);
273 this.mosaicMode_.init(); 274 mosaic.init();
275 mosaic.show();
274 } else { 276 } else {
275 this.setCurrentMode_(this.slideMode_); 277 this.setCurrentMode_(this.slideMode_);
276 /* TODO: consider nice blow-up animation for the first image */ 278 /* TODO: consider nice blow-up animation for the first image */
277 this.slideMode_.enter(null, function() { 279 this.slideMode_.enter(null, function() {
278 // Flash the toolbar briefly to show it is there. 280 // Flash the toolbar briefly to show it is there.
279 this.inactivityWatcher_.startActivity(); 281 this.inactivityWatcher_.startActivity();
280 this.inactivityWatcher_.stopActivity(Gallery.FIRST_FADE_TIMEOUT); 282 this.inactivityWatcher_.stopActivity(Gallery.FIRST_FADE_TIMEOUT);
281 // Load mosaic tiles in background so that the transition is smooth. 283 }.bind(this),
282 this.mosaicMode_.init(); 284 mosaic.init.bind(mosaic));
283 }.bind(this));
284 } 285 }
285 }; 286 };
286 287
287 /** 288 /**
288 * Close the Gallery. 289 * Close the Gallery.
289 * @private 290 * @private
290 */ 291 */
291 Gallery.prototype.close_ = function() { 292 Gallery.prototype.close_ = function() {
292 Gallery.getFileBrowserPrivate().isFullscreen(function(fullscreen) { 293 Gallery.getFileBrowserPrivate().isFullscreen(function(fullscreen) {
293 if (this.originalFullscreen_ != fullscreen) { 294 if (this.originalFullscreen_ != fullscreen) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (opt_event) 386 if (opt_event)
386 this.onUserAction_(); 387 this.onUserAction_();
387 388
388 this.changingMode_ = true; 389 this.changingMode_ = true;
389 390
390 var onModeChanged = function() { 391 var onModeChanged = function() {
391 this.changingMode_ = false; 392 this.changingMode_ = false;
392 if (opt_callback) opt_callback(); 393 if (opt_callback) opt_callback();
393 }.bind(this); 394 }.bind(this);
394 395
396 var tileIndex = Math.max(0, this.selectionModel_.selectedIndex);
397
398 var mosaic = this.mosaicMode_.getMosaic();
399 var tileRect = mosaic.getTileRect(tileIndex);
400
395 if (this.currentMode_ == this.slideMode_) { 401 if (this.currentMode_ == this.slideMode_) {
396 this.mosaicMode_.enter(); // This may change the viewport. 402 this.setCurrentMode_(this.mosaicMode_);
397 this.slideMode_.leave(this.mosaicMode_.getSelectedTileRect(), 403 mosaic.transform(
404 tileRect, this.slideMode_.getSelectedImageRect(), true /* instant */);
405 this.slideMode_.leave(tileRect,
398 function() { 406 function() {
399 this.setCurrentMode_(this.mosaicMode_); 407 // Animate back to normal position.
408 mosaic.transform();
409 mosaic.show();
400 onModeChanged(); 410 onModeChanged();
401 }.bind(this)); 411 }.bind(this));
402 } else { 412 } else {
403 this.slideMode_.enter(this.mosaicMode_.getSelectedTileRect(), 413 this.setCurrentMode_(this.slideMode_);
404 this.setCurrentMode_.bind(this, this.slideMode_), 414 this.slideMode_.enter(tileRect,
415 function() {
416 // Animate to zoomed position.
417 mosaic.transform(tileRect, this.slideMode_.getSelectedImageRect());
418 mosaic.hide();
419 }.bind(this),
405 onModeChanged); 420 onModeChanged);
406 } 421 }
407 }; 422 };
408 423
409 /** 424 /**
410 * Delete event handler. 425 * Delete event handler.
411 * @private 426 * @private
412 */ 427 */
413 Gallery.prototype.onDelete_ = function() { 428 Gallery.prototype.onDelete_ = function() {
414 this.onUserAction_(); 429 this.onUserAction_();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 this.toggleShare_(); // Hide the menu. 762 this.toggleShare_(); // Hide the menu.
748 this.executeWhenReady(api.executeTask.bind(api, taskId, urls)); 763 this.executeWhenReady(api.executeTask.bind(api, taskId, urls));
749 }.bind(this, task.taskId)); 764 }.bind(this, task.taskId));
750 } 765 }
751 766
752 var empty = this.shareMenu_.querySelector('.item') == null; 767 var empty = this.shareMenu_.querySelector('.item') == null;
753 ImageUtil.setAttribute(this.shareButton_, 'disabled', empty); 768 ImageUtil.setAttribute(this.shareButton_, 'disabled', empty);
754 this.shareMenu_.hidden = wasHidden || empty; 769 this.shareMenu_.hidden = wasHidden || empty;
755 }.bind(this)); 770 }.bind(this));
756 }; 771 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698