| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Implementation of a scrollbar for the custom scrolling behavior | 6 * Implementation of a scrollbar for the custom scrolling behavior |
| 7 * defined in [:Scroller:]. | 7 * defined in [:Scroller:]. |
| 8 */ | 8 */ |
| 9 class Scrollbar implements ScrollListener { | 9 class Scrollbar implements ScrollListener { |
| 10 /** | 10 /** |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 _onScrollerEnd(null); | 239 _onScrollerEnd(null); |
| 240 } | 240 } |
| 241 updateScrollbars(scrollX, scrollY); | 241 updateScrollbars(scrollX, scrollY); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void refresh() { | 244 void refresh() { |
| 245 if (_scrollInProgress == false && _hovering == false) { | 245 if (_scrollInProgress == false && _hovering == false) { |
| 246 // No need to refresh if not visible. | 246 // No need to refresh if not visible. |
| 247 return; | 247 return; |
| 248 } | 248 } |
| 249 _scroller._resize(); | 249 _scroller._resize(() { |
| 250 updateScrollbars(_scroller.getHorizontalOffset(), | 250 updateScrollbars(_scroller.getHorizontalOffset(), |
| 251 _scroller.getVerticalOffset()); | 251 _scroller.getVerticalOffset()); |
| 252 }); |
| 252 } | 253 } |
| 253 | 254 |
| 254 void updateScrollbars(num scrollX, num scrollY) { | 255 void updateScrollbars(num scrollX, num scrollY) { |
| 255 Size contentSize = _scroller._getAdjustedContentSize(); | 256 Size contentSize = _scroller._getAdjustedContentSize(); |
| 256 if (_scroller._shouldScrollHorizontally()) { | 257 if (_scroller._shouldScrollHorizontally()) { |
| 257 num scrollPercentX = _scroller.getHorizontalScrollPercent(scrollX); | 258 num scrollPercentX = _scroller.getHorizontalScrollPercent(scrollX); |
| 258 _updateScrollbar(_horizontalElement, scrollX, scrollPercentX, | 259 _updateScrollbar(_horizontalElement, scrollX, scrollPercentX, |
| 259 _scroller._scrollSize.width, | 260 _scroller._scrollSize.width, |
| 260 contentSize.width, 'right', 'width'); | 261 contentSize.width, 'right', 'width'); |
| 261 } | 262 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 style.setProperty(cssPos, '${pos}px', ''); | 342 style.setProperty(cssPos, '${pos}px', ''); |
| 342 if (_cachedSize[cssSize] != size) { | 343 if (_cachedSize[cssSize] != size) { |
| 343 _cachedSize[cssSize] = size; | 344 _cachedSize[cssSize] = size; |
| 344 style.setProperty(cssSize, '${size}px', ''); | 345 style.setProperty(cssSize, '${size}px', ''); |
| 345 } | 346 } |
| 346 if (element.parent == null) { | 347 if (element.parent == null) { |
| 347 _frame.nodes.add(element); | 348 _frame.nodes.add(element); |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 } | 351 } |
| OLD | NEW |