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

Side by Side Diff: ui/file_manager/gallery/js/image_editor/image_view.js

Issue 398283002: Gallery: Add the offset feature in the slide mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. 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 | « no previous file | ui/file_manager/gallery/js/image_editor/viewport.js » ('j') | 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 * The overlay displaying the image. 8 * The overlay displaying the image.
9 * 9 *
10 * @param {HTMLElement} container The container element. 10 * @param {HTMLElement} container The container element.
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 this.container_.removeChild(this.contentCanvas_); 486 this.container_.removeChild(this.contentCanvas_);
487 487
488 this.screenImage_ = this.document_.createElement('canvas'); 488 this.screenImage_ = this.document_.createElement('canvas');
489 this.screenImage_.className = 'image'; 489 this.screenImage_.className = 'image';
490 490
491 this.contentCanvas_ = content; 491 this.contentCanvas_ = content;
492 this.invalidateCaches(); 492 this.invalidateCaches();
493 this.viewport_.setImageSize( 493 this.viewport_.setImageSize(
494 opt_width || this.contentCanvas_.width, 494 opt_width || this.contentCanvas_.width,
495 opt_height || this.contentCanvas_.height); 495 opt_height || this.contentCanvas_.height);
496 this.viewport_.fitImage();
497 this.viewport_.update();
498 this.draw(); 496 this.draw();
499 497
500 this.container_.appendChild(this.screenImage_); 498 this.container_.appendChild(this.screenImage_);
501 499
502 this.preview_ = opt_preview; 500 this.preview_ = opt_preview;
503 // If this is not a thumbnail, cache the content and the screen-scale image. 501 // If this is not a thumbnail, cache the content and the screen-scale image.
504 if (this.hasValidImage()) { 502 if (this.hasValidImage()) {
505 // Insert the full resolution canvas into DOM so that it can be printed. 503 // Insert the full resolution canvas into DOM so that it can be printed.
506 this.container_.appendChild(this.contentCanvas_); 504 this.container_.appendChild(this.contentCanvas_);
507 this.contentCanvas_.classList.add('fullres'); 505 this.contentCanvas_.classList.add('fullres');
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 }; 837 };
840 838
841 /** 839 /**
842 * Default effect. It is not a no-op as it needs to adjust a canvas scale 840 * Default effect. It is not a no-op as it needs to adjust a canvas scale
843 * for devicePixelRatio. 841 * for devicePixelRatio.
844 * 842 *
845 * @constructor 843 * @constructor
846 * @extends {ImageView.Effect} 844 * @extends {ImageView.Effect}
847 */ 845 */
848 ImageView.Effect.None = function() { 846 ImageView.Effect.None = function() {
849 ImageView.Effect.call(this, 0); 847 ImageView.Effect.call(this, 0, 'easy-out');
850 }; 848 };
851 849
852 /** 850 /**
853 * Inherits from ImageView.Effect. 851 * Inherits from ImageView.Effect.
854 */ 852 */
855 ImageView.Effect.None.prototype = { __proto__: ImageView.Effect.prototype }; 853 ImageView.Effect.None.prototype = { __proto__: ImageView.Effect.prototype };
856 854
857 /** 855 /**
858 * @param {HTMLCanvasElement} element Element. 856 * @param {HTMLCanvasElement} element Element.
859 * @param {Viewport} viewport Current viewport. 857 * @param {Viewport} viewport Current viewport.
860 * @return {string} Transform string. 858 * @return {string} Transform string.
861 */ 859 */
862 ImageView.Effect.None.prototype.transform = function(element, viewport) { 860 ImageView.Effect.None.prototype.transform = function(element, viewport) {
863 return viewport.getTransformation(); 861 return viewport.getTransformation();
864 }; 862 };
865 863
866 /** 864 /**
867 * Slide effect. 865 * Slide effect.
868 * 866 *
869 * @param {number} direction -1 for left, 1 for right. 867 * @param {number} direction -1 for left, 1 for right.
870 * @param {boolean=} opt_slow True if slow (as in slideshow). 868 * @param {boolean=} opt_slow True if slow (as in slideshow).
871 * @constructor 869 * @constructor
872 * @extends {ImageView.Effect} 870 * @extends {ImageView.Effect}
873 */ 871 */
874 ImageView.Effect.Slide = function Slide(direction, opt_slow) { 872 ImageView.Effect.Slide = function Slide(direction, opt_slow) {
875 ImageView.Effect.call(this, 873 ImageView.Effect.call(this,
876 opt_slow ? 800 : ImageView.Effect.DEFAULT_DURATION, 'ease-in-out'); 874 opt_slow ? 800 : ImageView.Effect.DEFAULT_DURATION, 'ease-out');
877 this.direction_ = direction; 875 this.direction_ = direction;
878 this.slow_ = opt_slow; 876 this.slow_ = opt_slow;
879 this.shift_ = opt_slow ? 100 : 40; 877 this.shift_ = opt_slow ? 100 : 40;
880 if (this.direction_ < 0) this.shift_ = -this.shift_; 878 if (this.direction_ < 0) this.shift_ = -this.shift_;
881 }; 879 };
882 880
883 ImageView.Effect.Slide.prototype = { __proto__: ImageView.Effect.prototype }; 881 ImageView.Effect.Slide.prototype = { __proto__: ImageView.Effect.prototype };
884 882
885 /** 883 /**
886 * Reverses the slide effect. 884 * Reverses the slide effect.
(...skipping 19 matching lines...) Expand all
906 * @param {number} previousImageWidth Width of the full resolution image. 904 * @param {number} previousImageWidth Width of the full resolution image.
907 * @param {number} previousImageHeight Hieght of the full resolution image. 905 * @param {number} previousImageHeight Hieght of the full resolution image.
908 * @param {Rect} imageCropRect Crop rectangle in the full resolution image. 906 * @param {Rect} imageCropRect Crop rectangle in the full resolution image.
909 * @param {number=} opt_duration Duration of the effect. 907 * @param {number=} opt_duration Duration of the effect.
910 * @constructor 908 * @constructor
911 * @extends {ImageView.Effect} 909 * @extends {ImageView.Effect}
912 */ 910 */
913 ImageView.Effect.Zoom = function( 911 ImageView.Effect.Zoom = function(
914 previousImageWidth, previousImageHeight, imageCropRect, opt_duration) { 912 previousImageWidth, previousImageHeight, imageCropRect, opt_duration) {
915 ImageView.Effect.call(this, 913 ImageView.Effect.call(this,
916 opt_duration || ImageView.Effect.DEFAULT_DURATION); 914 opt_duration || ImageView.Effect.DEFAULT_DURATION, 'ease-out');
917 this.previousImageWidth_ = previousImageWidth; 915 this.previousImageWidth_ = previousImageWidth;
918 this.previousImageHeight_ = previousImageHeight; 916 this.previousImageHeight_ = previousImageHeight;
919 this.imageCropRect_ = imageCropRect; 917 this.imageCropRect_ = imageCropRect;
920 }; 918 };
921 919
922 ImageView.Effect.Zoom.prototype = { __proto__: ImageView.Effect.prototype }; 920 ImageView.Effect.Zoom.prototype = { __proto__: ImageView.Effect.prototype };
923 921
924 /** 922 /**
925 * @override 923 * @override
926 */ 924 */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 }; 966 };
969 967
970 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; 968 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype };
971 969
972 /** 970 /**
973 * @override 971 * @override
974 */ 972 */
975 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { 973 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) {
976 return viewport.getInverseTransformForRotatedImage(this.orientation_); 974 return viewport.getInverseTransformForRotatedImage(this.orientation_);
977 }; 975 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698