| Index: ui/file_manager/gallery/js/image_editor/viewport.js
|
| diff --git a/ui/file_manager/gallery/js/image_editor/viewport.js b/ui/file_manager/gallery/js/image_editor/viewport.js
|
| index df53d7476c4b98db1aa87ea62e9dbaea90dfd9cf..d4122162f877bb08cc88e8b90001e77aa9c4bfae 100644
|
| --- a/ui/file_manager/gallery/js/image_editor/viewport.js
|
| +++ b/ui/file_manager/gallery/js/image_editor/viewport.js
|
| @@ -30,6 +30,21 @@ function Viewport() {
|
| * @private
|
| */
|
| this.scale_ = 1;
|
| +
|
| + /**
|
| + * Index of zoom ratio. 0 is "zoom ratio = 1".
|
| + * @type {number}
|
| + * @private
|
| + */
|
| + this.zoomIndex_ = 0;
|
| +
|
| + /**
|
| + * Zoom ratio specified by user operations.
|
| + * @type {number}
|
| + * @private
|
| + */
|
| + this.zoom_ = 1;
|
| +
|
| this.offsetX_ = 0;
|
| this.offsetY_ = 0;
|
|
|
| @@ -39,6 +54,22 @@ function Viewport() {
|
| }
|
|
|
| /**
|
| + * Zoom ratios.
|
| + *
|
| + * @type {Object.<string, number>}
|
| + * @const
|
| + */
|
| +Viewport.ZOOM_RATIOS = Object.freeze({
|
| + '3': 3,
|
| + '2': 2,
|
| + '1': 1.5,
|
| + '0': 1,
|
| + '-1': 0.75,
|
| + '-2': 0.5,
|
| + '-3': 0.25
|
| +});
|
| +
|
| +/**
|
| * @param {number} width Image width.
|
| * @param {number} height Image height.
|
| */
|
| @@ -57,6 +88,28 @@ Viewport.prototype.setScreenSize = function(width, height) {
|
| };
|
|
|
| /**
|
| + * Sets the new zoom ratio.
|
| + * @param {number} zoomIndex New zoom index.
|
| + */
|
| +Viewport.prototype.setZoomIndex = function(zoomIndex) {
|
| + // Ignore the invalid zoomIndex.
|
| + if (!Viewport.ZOOM_RATIOS[zoomIndex.toString()])
|
| + return;
|
| +
|
| + this.zoomIndex_ = zoomIndex;
|
| + this.zoom_ = Viewport.ZOOM_RATIOS[zoomIndex];
|
| + this.invalidateCaches();
|
| +};
|
| +
|
| +/**
|
| + * Returns the current zoom index.
|
| + * @return {number} Zoon index.
|
| + */
|
| +Viewport.prototype.getZoomIndex = function() {
|
| + return this.zoomIndex_;
|
| +};
|
| +
|
| +/**
|
| * Set the size by an HTML element.
|
| *
|
| * @param {HTMLElement} frame The element acting as the "screen".
|
| @@ -388,7 +441,7 @@ Viewport.prototype.update = function() {
|
| * @return {string} Transformation description.
|
| */
|
| Viewport.prototype.getTransformation = function() {
|
| - return 'scale(' + (1 / window.devicePixelRatio) + ')';
|
| + return 'scale(' + (1 / window.devicePixelRatio * this.zoom_) + ')';
|
| };
|
|
|
| /**
|
|
|