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

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

Issue 402863002: Specify canvas size by using CSS width/height. (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 | « ui/file_manager/gallery/js/image_editor/image_view.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 * Viewport class controls the way the image is displayed (scale, offset etc). 8 * Viewport class controls the way the image is displayed (scale, offset etc).
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 this.imageBoundsOnScreenClipped_ = new Rect( 430 this.imageBoundsOnScreenClipped_ = new Rect(
431 left, top, right - left, bottom - top); 431 left, top, right - left, bottom - top);
432 }; 432 };
433 433
434 /** 434 /**
435 * Obtains CSS transformation for the screen image. 435 * Obtains CSS transformation for the screen image.
436 * @return {string} Transformation description. 436 * @return {string} Transformation description.
437 */ 437 */
438 Viewport.prototype.getTransformation = function() { 438 Viewport.prototype.getTransformation = function() {
439 return 'translate(' + this.offsetX_ + 'px, ' + this.offsetY_ + 'px) ' + 439 return 'translate(' + this.offsetX_ + 'px, ' + this.offsetY_ + 'px) ' +
440 'scale(' + (1 / window.devicePixelRatio * this.zoom_) + ')'; 440 'scale(' + this.zoom_ + ')';
441 }; 441 };
442 442
443 /** 443 /**
444 * Obtains shift CSS transformation for the screen image. 444 * Obtains shift CSS transformation for the screen image.
445 * @param {number} dx Amount of shift. 445 * @param {number} dx Amount of shift.
446 * @return {string} Transformation description. 446 * @return {string} Transformation description.
447 */ 447 */
448 Viewport.prototype.getShiftTransformation = function(dx) { 448 Viewport.prototype.getShiftTransformation = function(dx) {
449 return 'translateX(' + dx + 'px) ' + this.getTransformation(); 449 return 'translateX(' + dx + 'px) ' + this.getTransformation();
450 }; 450 };
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 var screenWidth = this.screenBounds_.width; 515 var screenWidth = this.screenBounds_.width;
516 var screenHeight = this.screenBounds_.height; 516 var screenHeight = this.screenBounds_.height;
517 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2; 517 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2;
518 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2; 518 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2;
519 return [ 519 return [
520 'translate(' + dx + 'px,' + dy + 'px)', 520 'translate(' + dx + 'px,' + dy + 'px)',
521 'scale(' + scaleX + ',' + scaleY + ')', 521 'scale(' + scaleX + ',' + scaleY + ')',
522 this.getTransformation() 522 this.getTransformation()
523 ].join(' '); 523 ].join(' ');
524 }; 524 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698