OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Predefined zoom factors to be used when zooming in/out. These are in | 6 * Predefined zoom factors to be used when zooming in/out. These are in |
7 * ascending order. | 7 * ascending order. |
8 */ | 8 */ |
9 var ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1, | 9 var ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1, |
10 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5]; | 10 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5]; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 this.window_.scrollTo( | 122 this.window_.scrollTo( |
123 currentScrollPos[0] * newZoom - this.window_.innerWidth / 2, | 123 currentScrollPos[0] * newZoom - this.window_.innerWidth / 2, |
124 currentScrollPos[1] * newZoom - this.window_.innerHeight / 2); | 124 currentScrollPos[1] * newZoom - this.window_.innerHeight / 2); |
125 }, | 125 }, |
126 | 126 |
127 /** | 127 /** |
128 * @private | 128 * @private |
129 * Called when the viewport should be updated. | 129 * Called when the viewport should be updated. |
130 */ | 130 */ |
131 updateViewport_: function() { | 131 updateViewport_: function() { |
132 // Shift the toolbar so that it doesn't move when the scrollbars display | |
133 var needsScrollbars = this.documentHasScrollbars(); | 132 var needsScrollbars = this.documentHasScrollbars(); |
| 133 var page = this.getMostVisiblePage(); |
134 this.viewportChangedCallback_(this.zoom_, | 134 this.viewportChangedCallback_(this.zoom_, |
135 this.window_.pageXOffset, | 135 this.window_.pageXOffset, |
136 this.window_.pageYOffset, | 136 this.window_.pageYOffset, |
137 this.scrollbarWidth_, | 137 this.scrollbarWidth_, |
138 needsScrollbars); | 138 needsScrollbars, |
| 139 page); |
139 }, | 140 }, |
140 | 141 |
141 /** | 142 /** |
142 * @private | 143 * @private |
143 * Returns a rect representing the current viewport. | 144 * Returns a rect representing the current viewport. |
144 * @return {Object} a rect representing the current viewport. | 145 * @return {Object} a rect representing the current viewport. |
145 */ | 146 */ |
146 getCurrentViewportRect_: function() { | 147 getCurrentViewportRect_: function() { |
147 return { | 148 return { |
148 x: this.window_.pageXOffset / this.zoom_, | 149 x: this.window_.pageXOffset / this.zoom_, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 * Set the dimensions of the document. | 299 * Set the dimensions of the document. |
299 * @param {Object} documentDimensions the dimensions of the document | 300 * @param {Object} documentDimensions the dimensions of the document |
300 */ | 301 */ |
301 setDocumentDimensions: function(documentDimensions) { | 302 setDocumentDimensions: function(documentDimensions) { |
302 this.documentDimensions_ = documentDimensions; | 303 this.documentDimensions_ = documentDimensions; |
303 this.pageDimensions_ = this.documentDimensions_.pageDimensions; | 304 this.pageDimensions_ = this.documentDimensions_.pageDimensions; |
304 this.contentSizeChanged_(); | 305 this.contentSizeChanged_(); |
305 this.updateViewport_(); | 306 this.updateViewport_(); |
306 } | 307 } |
307 }; | 308 }; |
OLD | NEW |