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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Start hiding immediately if we aren't | 148 // Start hiding immediately if we aren't |
149 // scrolling or already in the process of | 149 // scrolling or already in the process of |
150 // hidng the scrollbar | 150 // hidng the scrollbar |
151 if (!_scrollInProgress && _timer == null) { | 151 if (!_scrollInProgress && _timer == null) { |
152 _boundHideFn(); | 152 _boundHideFn(); |
153 } | 153 } |
154 }); | 154 }); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 void _onStart(UIEvent e) { | 158 void _onStart(/*MouseEvent | Touch*/ e) { |
159 Element elementOver = e.target; | 159 Element elementOver = e.target; |
160 if (elementOver == _verticalElement || | 160 if (elementOver == _verticalElement || |
161 elementOver == _horizontalElement) { | 161 elementOver == _horizontalElement) { |
162 _currentScrollVertical = elementOver == _verticalElement; | 162 _currentScrollVertical = elementOver == _verticalElement; |
163 if (_currentScrollVertical) { | 163 if (_currentScrollVertical) { |
164 _currentScrollStartMouse = e.page.y; | 164 _currentScrollStartMouse = e.page.y; |
165 _currentScrollStartOffset = _scroller.getVerticalOffset(); | 165 _currentScrollStartOffset = _scroller.getVerticalOffset(); |
166 } else { | 166 } else { |
167 _currentScrollStartMouse = e.page.x; | 167 _currentScrollStartMouse = e.page.x; |
168 _currentScrollStartOffset = _scroller.getHorizontalOffset(); | 168 _currentScrollStartOffset = _scroller.getHorizontalOffset(); |
(...skipping 20 matching lines...) Expand all Loading... |
189 void _refreshScrollRatioHelper(num frameSize, num contentSize) { | 189 void _refreshScrollRatioHelper(num frameSize, num contentSize) { |
190 num frameTravelDistance = frameSize - _defaultScrollSize( | 190 num frameTravelDistance = frameSize - _defaultScrollSize( |
191 frameSize, contentSize) -_PADDING_LENGTH * 2; | 191 frameSize, contentSize) -_PADDING_LENGTH * 2; |
192 if (frameTravelDistance < 0.001) { | 192 if (frameTravelDistance < 0.001) { |
193 _currentScrollRatio = 0; | 193 _currentScrollRatio = 0; |
194 } else { | 194 } else { |
195 _currentScrollRatio = (contentSize - frameSize) / frameTravelDistance; | 195 _currentScrollRatio = (contentSize - frameSize) / frameTravelDistance; |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 void _onMove(UIEvent e) { | 199 void _onMove(/*MouseEvent | Touch*/ e) { |
200 if (!_scrollBarDragInProgress) { | 200 if (!_scrollBarDragInProgress) { |
201 return; | 201 return; |
202 } | 202 } |
203 _refreshScrollRatio(); | 203 _refreshScrollRatio(); |
204 int coordinate = _currentScrollVertical ? e.page.y : e.page.x; | 204 int coordinate = _currentScrollVertical ? e.page.y : e.page.x; |
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; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 style.setProperty(cssPos, '${pos}px', ''); | 346 style.setProperty(cssPos, '${pos}px', ''); |
347 if (_cachedSize[cssSize] != size) { | 347 if (_cachedSize[cssSize] != size) { |
348 _cachedSize[cssSize] = size; | 348 _cachedSize[cssSize] = size; |
349 style.setProperty(cssSize, '${size}px', ''); | 349 style.setProperty(cssSize, '${size}px', ''); |
350 } | 350 } |
351 if (element.parent == null) { | 351 if (element.parent == null) { |
352 _frame.nodes.add(element); | 352 _frame.nodes.add(element); |
353 } | 353 } |
354 } | 354 } |
355 } | 355 } |
OLD | NEW |