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 part of touch; | 5 part of touch; |
6 | 6 |
7 /** | 7 /** |
8 * Implementation of a scrollbar for the custom scrolling behavior | 8 * Implementation of a scrollbar for the custom scrolling behavior |
9 * defined in [:Scroller:]. | 9 * defined in [:Scroller:]. |
10 */ | 10 */ |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 _refreshScrollRatio(); | 203 _refreshScrollRatio(); |
204 int coordinate = _currentScrollVertical ? e.pageY : e.pageX; | 204 int coordinate = _currentScrollVertical ? e.pageY : e.pageX; |
205 num delta = (coordinate - _currentScrollStartMouse) * _currentScrollRatio; | 205 num delta = (coordinate - _currentScrollStartMouse) * _currentScrollRatio; |
206 if (delta != 0) { | 206 if (delta != 0) { |
207 num x; | 207 num x; |
208 num y; | 208 num y; |
209 _currentScrollStartOffset -= delta; | 209 _currentScrollStartOffset -= delta; |
210 if (_currentScrollVertical) { | 210 if (_currentScrollVertical) { |
211 x = _scroller.getHorizontalOffset(); | 211 x = _scroller.getHorizontalOffset(); |
212 y = _currentScrollStartOffset.toInt(); | 212 y = _currentScrollStartOffset.truncate(); |
213 } else { | 213 } else { |
214 x = _currentScrollStartOffset.toInt(); | 214 x = _currentScrollStartOffset.truncate(); |
215 y = _scroller.getVerticalOffset(); | 215 y = _scroller.getVerticalOffset(); |
216 } | 216 } |
217 _scroller.setPosition(x, y); | 217 _scroller.setPosition(x, y); |
218 } | 218 } |
219 _currentScrollStartMouse = coordinate; | 219 _currentScrollStartMouse = coordinate; |
220 } | 220 } |
221 | 221 |
222 void _onEnd(UIEvent e) { | 222 void _onEnd(UIEvent e) { |
223 _scrollBarDragInProgress = false; | 223 _scrollBarDragInProgress = false; |
224 // TODO(jacobr): make scrollbar less tightly coupled to the scroller. | 224 // TODO(jacobr): make scrollbar less tightly coupled to the scroller. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 style.setProperty(cssPos, '${pos}px', ''); | 345 style.setProperty(cssPos, '${pos}px', ''); |
346 if (_cachedSize[cssSize] != size) { | 346 if (_cachedSize[cssSize] != size) { |
347 _cachedSize[cssSize] = size; | 347 _cachedSize[cssSize] = size; |
348 style.setProperty(cssSize, '${size}px', ''); | 348 style.setProperty(cssSize, '${size}px', ''); |
349 } | 349 } |
350 if (element.parent == null) { | 350 if (element.parent == null) { |
351 _frame.nodes.add(element); | 351 _frame.nodes.add(element); |
352 } | 352 } |
353 } | 353 } |
354 } | 354 } |
OLD | NEW |