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 '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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 * Sets the new zoom ratio. | 91 * Sets the new zoom ratio. |
92 * @param {number} zoomIndex New zoom index. | 92 * @param {number} zoomIndex New zoom index. |
93 */ | 93 */ |
94 Viewport.prototype.setZoomIndex = function(zoomIndex) { | 94 Viewport.prototype.setZoomIndex = function(zoomIndex) { |
95 // Ignore the invalid zoomIndex. | 95 // Ignore the invalid zoomIndex. |
96 if (!Viewport.ZOOM_RATIOS[zoomIndex.toString()]) | 96 if (!Viewport.ZOOM_RATIOS[zoomIndex.toString()]) |
97 return; | 97 return; |
98 | 98 |
99 this.zoomIndex_ = zoomIndex; | 99 this.zoomIndex_ = zoomIndex; |
100 this.zoom_ = Viewport.ZOOM_RATIOS[zoomIndex]; | 100 this.zoom_ = Viewport.ZOOM_RATIOS[zoomIndex]; |
101 this.invalidateCaches(); | |
102 }; | 101 }; |
103 | 102 |
104 /** | 103 /** |
105 * Returns the current zoom index. | 104 * Returns the current zoom index. |
106 * @return {number} Zoon index. | 105 * @return {number} Zoon index. |
107 */ | 106 */ |
108 Viewport.prototype.getZoomIndex = function() { | 107 Viewport.prototype.getZoomIndex = function() { |
109 return this.zoomIndex_; | 108 return this.zoomIndex_; |
110 }; | 109 }; |
111 | 110 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 var screenWidth = this.screenBounds_.width; | 519 var screenWidth = this.screenBounds_.width; |
521 var screenHeight = this.screenBounds_.height; | 520 var screenHeight = this.screenBounds_.height; |
522 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2; | 521 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2; |
523 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2; | 522 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2; |
524 return [ | 523 return [ |
525 'translate(' + dx + 'px,' + dy + 'px)', | 524 'translate(' + dx + 'px,' + dy + 'px)', |
526 'scale(' + scaleX + ',' + scaleY + ')', | 525 'scale(' + scaleX + ',' + scaleY + ')', |
527 this.getTransformation() | 526 this.getTransformation() |
528 ].join(' '); | 527 ].join(' '); |
529 }; | 528 }; |
OLD | NEW |