| 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 * The overlay displaying the image. | 6 * The overlay displaying the image. |
| 7 * | 7 * |
| 8 * @param {!HTMLElement} container The container element. | 8 * @param {!HTMLElement} container The container element. |
| 9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
| 10 * @param {!MetadataModel} metadataModel | 10 * @param {!MetadataModel} metadataModel |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 */ | 694 */ |
| 695 ImageView.prototype.setTransform_ = function( | 695 ImageView.prototype.setTransform_ = function( |
| 696 element, viewport, opt_effect, opt_duration) { | 696 element, viewport, opt_effect, opt_duration) { |
| 697 if (!opt_effect) | 697 if (!opt_effect) |
| 698 opt_effect = new ImageView.Effect.None(); | 698 opt_effect = new ImageView.Effect.None(); |
| 699 if (typeof opt_duration !== 'number') | 699 if (typeof opt_duration !== 'number') |
| 700 opt_duration = opt_effect.getDuration(); | 700 opt_duration = opt_effect.getDuration(); |
| 701 element.style.transitionDuration = opt_duration + 'ms'; | 701 element.style.transitionDuration = opt_duration + 'ms'; |
| 702 element.style.transitionTimingFunction = opt_effect.getTiming(); | 702 element.style.transitionTimingFunction = opt_effect.getTiming(); |
| 703 element.style.transform = opt_effect.transform(element, viewport); | 703 element.style.transform = opt_effect.transform(element, viewport); |
| 704 var imageBounds = viewport.getImageElementBoundsOnScreen(); | |
| 705 element.style.left = imageBounds.left + 'px'; | |
| 706 element.style.top = imageBounds.top + 'px'; | |
| 707 element.style.width = imageBounds.width + 'px'; | |
| 708 element.style.height = imageBounds.height + 'px'; | |
| 709 }; | 704 }; |
| 710 | 705 |
| 711 /** | 706 /** |
| 712 * Creates zoom effect object. | 707 * Creates zoom effect object. |
| 713 * @param {!ImageRect} screenRect Target rectangle in screen coordinates. | 708 * @param {!ImageRect} screenRect Target rectangle in screen coordinates. |
| 714 * @return {!ImageView.Effect} Zoom effect object. | 709 * @return {!ImageView.Effect} Zoom effect object. |
| 715 */ | 710 */ |
| 716 ImageView.prototype.createZoomEffect = function(screenRect) { | 711 ImageView.prototype.createZoomEffect = function(screenRect) { |
| 717 return new ImageView.Effect.ZoomToScreen( | 712 return new ImageView.Effect.ZoomToScreen( |
| 718 screenRect, | 713 screenRect, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 | 866 |
| 872 /** | 867 /** |
| 873 * Inherits from ImageView.Effect. | 868 * Inherits from ImageView.Effect. |
| 874 */ | 869 */ |
| 875 ImageView.Effect.None.prototype = { __proto__: ImageView.Effect.prototype }; | 870 ImageView.Effect.None.prototype = { __proto__: ImageView.Effect.prototype }; |
| 876 | 871 |
| 877 /** | 872 /** |
| 878 * @override | 873 * @override |
| 879 */ | 874 */ |
| 880 ImageView.Effect.None.prototype.transform = function(element, viewport) { | 875 ImageView.Effect.None.prototype.transform = function(element, viewport) { |
| 881 return viewport.getTransformation(); | 876 return viewport.getTransformation(element.width, element.height); |
| 882 }; | 877 }; |
| 883 | 878 |
| 884 /** | 879 /** |
| 885 * Slide effect. | 880 * Slide effect. |
| 886 * | 881 * |
| 887 * @param {number} direction -1 for left, 1 for right. | 882 * @param {number} direction -1 for left, 1 for right. |
| 888 * @param {boolean=} opt_slow True if slow (as in slideshow). | 883 * @param {boolean=} opt_slow True if slow (as in slideshow). |
| 889 * @constructor | 884 * @constructor |
| 890 * @extends {ImageView.Effect} | 885 * @extends {ImageView.Effect} |
| 891 * @struct | 886 * @struct |
| (...skipping 13 matching lines...) Expand all Loading... |
| 905 * @override | 900 * @override |
| 906 */ | 901 */ |
| 907 ImageView.Effect.Slide.prototype.getReverse = function() { | 902 ImageView.Effect.Slide.prototype.getReverse = function() { |
| 908 return new ImageView.Effect.Slide(-this.direction_, this.slow_); | 903 return new ImageView.Effect.Slide(-this.direction_, this.slow_); |
| 909 }; | 904 }; |
| 910 | 905 |
| 911 /** | 906 /** |
| 912 * @override | 907 * @override |
| 913 */ | 908 */ |
| 914 ImageView.Effect.Slide.prototype.transform = function(element, viewport) { | 909 ImageView.Effect.Slide.prototype.transform = function(element, viewport) { |
| 915 return viewport.getShiftTransformation(this.shift_); | 910 return viewport.getTransformation( |
| 911 element.width, element.height, this.shift_); |
| 916 }; | 912 }; |
| 917 | 913 |
| 918 /** | 914 /** |
| 919 * Zoom effect. | 915 * Zoom effect. |
| 920 * | 916 * |
| 921 * Animates the original rectangle to the target rectangle. | 917 * Animates the original rectangle to the target rectangle. |
| 922 * | 918 * |
| 923 * @param {number} previousImageWidth Width of the full resolution image. | 919 * @param {number} previousImageWidth Width of the full resolution image. |
| 924 * @param {number} previousImageHeight Height of the full resolution image. | 920 * @param {number} previousImageHeight Height of the full resolution image. |
| 925 * @param {!ImageRect} imageCropRect Crop rectangle in the full resolution | 921 * @param {!ImageRect} imageCropRect Crop rectangle in the full resolution |
| (...skipping 11 matching lines...) Expand all Loading... |
| 937 this.previousImageHeight_ = previousImageHeight; | 933 this.previousImageHeight_ = previousImageHeight; |
| 938 this.imageCropRect_ = imageCropRect; | 934 this.imageCropRect_ = imageCropRect; |
| 939 }; | 935 }; |
| 940 | 936 |
| 941 ImageView.Effect.Zoom.prototype = { __proto__: ImageView.Effect.prototype }; | 937 ImageView.Effect.Zoom.prototype = { __proto__: ImageView.Effect.prototype }; |
| 942 | 938 |
| 943 /** | 939 /** |
| 944 * @override | 940 * @override |
| 945 */ | 941 */ |
| 946 ImageView.Effect.Zoom.prototype.transform = function(element, viewport) { | 942 ImageView.Effect.Zoom.prototype.transform = function(element, viewport) { |
| 947 return viewport.getInverseTransformForCroppedImage( | 943 return viewport.getCroppingTransformation( |
| 948 this.previousImageWidth_, this.previousImageHeight_, this.imageCropRect_); | 944 element.width, |
| 945 element.height, |
| 946 this.previousImageWidth_, |
| 947 this.previousImageHeight_, |
| 948 this.imageCropRect_); |
| 949 }; | 949 }; |
| 950 | 950 |
| 951 /** | 951 /** |
| 952 * Effect to zoom to a screen rectangle. | 952 * Effect to zoom to a screen rectangle. |
| 953 * | 953 * |
| 954 * @param {!ImageRect} screenRect Rectangle in the application window's | 954 * @param {!ImageRect} screenRect Rectangle in the application window's |
| 955 * coordinate. | 955 * coordinate. |
| 956 * @param {number=} opt_duration Duration of effect. | 956 * @param {number=} opt_duration Duration of effect. |
| 957 * @constructor | 957 * @constructor |
| 958 * @extends {ImageView.Effect} | 958 * @extends {ImageView.Effect} |
| 959 * @struct | 959 * @struct |
| 960 */ | 960 */ |
| 961 ImageView.Effect.ZoomToScreen = function(screenRect, opt_duration) { | 961 ImageView.Effect.ZoomToScreen = function(screenRect, opt_duration) { |
| 962 ImageView.Effect.call(this, opt_duration || | 962 ImageView.Effect.call(this, opt_duration || |
| 963 ImageView.Effect.DEFAULT_DURATION); | 963 ImageView.Effect.DEFAULT_DURATION); |
| 964 this.screenRect_ = screenRect; | 964 this.screenRect_ = screenRect; |
| 965 }; | 965 }; |
| 966 | 966 |
| 967 ImageView.Effect.ZoomToScreen.prototype = { | 967 ImageView.Effect.ZoomToScreen.prototype = { |
| 968 __proto__: ImageView.Effect.prototype | 968 __proto__: ImageView.Effect.prototype |
| 969 }; | 969 }; |
| 970 | 970 |
| 971 /** | 971 /** |
| 972 * @override | 972 * @override |
| 973 */ | 973 */ |
| 974 ImageView.Effect.ZoomToScreen.prototype.transform = function( | 974 ImageView.Effect.ZoomToScreen.prototype.transform = function( |
| 975 element, viewport) { | 975 element, viewport) { |
| 976 return viewport.getScreenRectTransformForImage(this.screenRect_); | 976 return viewport.getScreenRectTransformation( |
| 977 element.width, |
| 978 element.height, |
| 979 this.screenRect_); |
| 977 }; | 980 }; |
| 978 | 981 |
| 979 /** | 982 /** |
| 980 * Rotation effect. | 983 * Rotation effect. |
| 981 * | 984 * |
| 982 * @param {boolean} orientation Orientation of rotation. True is for clockwise | 985 * @param {boolean} orientation Orientation of rotation. True is for clockwise |
| 983 * and false is for counterclockwise. | 986 * and false is for counterclockwise. |
| 984 * @constructor | 987 * @constructor |
| 985 * @extends {ImageView.Effect} | 988 * @extends {ImageView.Effect} |
| 986 * @struct | 989 * @struct |
| 987 */ | 990 */ |
| 988 ImageView.Effect.Rotate = function(orientation) { | 991 ImageView.Effect.Rotate = function(orientation) { |
| 989 ImageView.Effect.call(this, ImageView.Effect.DEFAULT_DURATION); | 992 ImageView.Effect.call(this, ImageView.Effect.DEFAULT_DURATION); |
| 990 this.orientation_ = orientation; | 993 this.orientation_ = orientation; |
| 991 }; | 994 }; |
| 992 | 995 |
| 993 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 996 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
| 994 | 997 |
| 995 /** | 998 /** |
| 996 * @override | 999 * @override |
| 997 */ | 1000 */ |
| 998 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 1001 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
| 999 return viewport.getInverseTransformForRotatedImage(this.orientation_); | 1002 return viewport.getRotatingTransformation( |
| 1003 element.width, element.height, this.orientation_ ? -1 : 1); |
| 1000 }; | 1004 }; |
| OLD | NEW |