OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // require: list_selection_model.js | 5 // require: list_selection_model.js |
6 // require: list_selection_controller.js | 6 // require: list_selection_controller.js |
7 // require: list.js | 7 // require: list.js |
8 | 8 |
9 /** | 9 /** |
10 * @fileoverview This implements a grid control. Grid contains a bunch of | 10 * @fileoverview This implements a grid control. Grid contains a bunch of |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 getItemsInViewPort: function(scrollTop, clientHeight) { | 161 getItemsInViewPort: function(scrollTop, clientHeight) { |
162 var itemHeight = this.getDefaultItemHeight_(); | 162 var itemHeight = this.getDefaultItemHeight_(); |
163 var firstIndex = | 163 var firstIndex = |
164 this.autoExpands ? 0 : this.getIndexForListOffset_(scrollTop); | 164 this.autoExpands ? 0 : this.getIndexForListOffset_(scrollTop); |
165 var columns = this.columns; | 165 var columns = this.columns; |
166 var count = this.autoExpands_ ? this.dataModel.length : Math.max( | 166 var count = this.autoExpands_ ? this.dataModel.length : Math.max( |
167 columns * (Math.ceil(clientHeight / itemHeight) + 1), | 167 columns * (Math.ceil(clientHeight / itemHeight) + 1), |
168 this.countItemsInRange_(firstIndex, scrollTop + clientHeight)); | 168 this.countItemsInRange_(firstIndex, scrollTop + clientHeight)); |
169 count = columns * Math.ceil(count / columns); | 169 count = columns * Math.ceil(count / columns); |
170 count = Math.min(count, this.dataModel.length - firstIndex); | 170 count = Math.min(count, this.dataModel.length - firstIndex); |
171 return count; | 171 return { |
| 172 first: firstIndex, |
| 173 length: count, |
| 174 last: firstIndex + count - 1 |
| 175 }; |
172 }, | 176 }, |
173 | 177 |
174 /** | 178 /** |
175 * Adds items to the list and {@code newCachedItems}. | 179 * Adds items to the list and {@code newCachedItems}. |
176 * @param {number} firstIndex The index of first item, inclusively. | 180 * @param {number} firstIndex The index of first item, inclusively. |
177 * @param {number} lastIndex The index of last item, exclusively. | 181 * @param {number} lastIndex The index of last item, exclusively. |
178 * @param {Object.<string, ListItem>} cachedItems Old items cache. | 182 * @param {Object.<string, ListItem>} cachedItems Old items cache. |
179 * @param {Object.<string, ListItem>} newCachedItems New items cache. | 183 * @param {Object.<string, ListItem>} newCachedItems New items cache. |
180 * @override | 184 * @override |
181 */ | 185 */ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 return index + 1; | 296 return index + 1; |
293 } | 297 } |
294 }; | 298 }; |
295 | 299 |
296 return { | 300 return { |
297 Grid: Grid, | 301 Grid: Grid, |
298 GridItem: GridItem, | 302 GridItem: GridItem, |
299 GridSelectionController: GridSelectionController | 303 GridSelectionController: GridSelectionController |
300 } | 304 } |
301 }); | 305 }); |
OLD | NEW |