Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: samples/swarm/swarm_ui_lib/touch/Scrollbar.dart

Issue 12212200: "Reverting 18531" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 */ 45 */
46 Function _boundHideFn; 46 Function _boundHideFn;
47 47
48 Element _verticalElement; 48 Element _verticalElement;
49 Element _horizontalElement; 49 Element _horizontalElement;
50 50
51 int _currentScrollStartMouse; 51 int _currentScrollStartMouse;
52 num _currentScrollStartOffset; 52 num _currentScrollStartOffset;
53 bool _currentScrollVertical; 53 bool _currentScrollVertical;
54 num _currentScrollRatio; 54 num _currentScrollRatio;
55 Timer _timer; 55 num _timerId;
56 56
57 bool _displayOnHover; 57 bool _displayOnHover;
58 bool _hovering = false; 58 bool _hovering = false;
59 59
60 Scrollbar(Scroller scroller, [displayOnHover = true]) : 60 Scrollbar(Scroller scroller, [displayOnHover = true]) :
61 _displayOnHover = displayOnHover, 61 _displayOnHover = displayOnHover,
62 _scroller = scroller, 62 _scroller = scroller,
63 _frame = scroller.getFrame(), 63 _frame = scroller.getFrame(),
64 _cachedSize = new Map<String, num>() { 64 _cachedSize = new Map<String, num>() {
65 _boundHideFn = () { _showScrollbars(false); }; 65 _boundHideFn = () { _showScrollbars(false); };
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 _cancelTimeout(); 141 _cancelTimeout();
142 _showScrollbars(true); 142 _showScrollbars(true);
143 refresh(); 143 refresh();
144 } 144 }
145 }); 145 });
146 _frame.onMouseOut.listen((e) { 146 _frame.onMouseOut.listen((e) {
147 _hovering = false; 147 _hovering = false;
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 && _timerId == null) {
152 _boundHideFn(); 152 _boundHideFn();
153 } 153 }
154 }); 154 });
155 } 155 }
156 } 156 }
157 157
158 void _onStart(UIEvent e) { 158 void _onStart(UIEvent 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) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 _scroller._onScrollerDragEnd.add( 225 _scroller._onScrollerDragEnd.add(
226 new Event(ScrollerEventType.DRAG_END)); 226 new Event(ScrollerEventType.DRAG_END));
227 } 227 }
228 228
229 229
230 /** 230 /**
231 * When scrolling ends, schedule a timeout to hide the scrollbars. 231 * When scrolling ends, schedule a timeout to hide the scrollbars.
232 */ 232 */
233 void _onScrollerEnd(Event e) { 233 void _onScrollerEnd(Event e) {
234 _cancelTimeout(); 234 _cancelTimeout();
235 _timer = new Timer(const Duration(milliseconds: _DISPLAY_TIME), 235 _timerId = window.setTimeout(_boundHideFn, _DISPLAY_TIME);
236 _boundHideFn);
237 _scrollInProgress = false; 236 _scrollInProgress = false;
238 } 237 }
239 void onScrollerMoved(num scrollX, num scrollY, bool decelerating) { 238 void onScrollerMoved(num scrollX, num scrollY, bool decelerating) {
240 if (_scrollInProgress == false) { 239 if (_scrollInProgress == false) {
241 // Display the scrollbar and then immediately prepare to hide it... 240 // Display the scrollbar and then immediately prepare to hide it...
242 _onScrollerStart(null); 241 _onScrollerStart(null);
243 _onScrollerEnd(null); 242 _onScrollerEnd(null);
244 } 243 }
245 updateScrollbars(scrollX, scrollY); 244 updateScrollbars(scrollX, scrollY);
246 } 245 }
(...skipping 28 matching lines...) Expand all
275 /** 274 /**
276 * When scrolling starts, show scrollbars and clear hide intervals. 275 * When scrolling starts, show scrollbars and clear hide intervals.
277 */ 276 */
278 void _onScrollerStart(Event e) { 277 void _onScrollerStart(Event e) {
279 _scrollInProgress = true; 278 _scrollInProgress = true;
280 _cancelTimeout(); 279 _cancelTimeout();
281 _showScrollbars(true); 280 _showScrollbars(true);
282 } 281 }
283 282
284 void _cancelTimeout() { 283 void _cancelTimeout() {
285 if (_timer != null) { 284 if (_timerId != null) {
286 _timer.cancel(); 285 window.clearTimeout(_timerId);
287 _timer = null; 286 _timerId = null;
288 } 287 }
289 } 288 }
290 289
291 /** 290 /**
292 * Show or hide the scrollbars by changing the opacity. 291 * Show or hide the scrollbars by changing the opacity.
293 */ 292 */
294 void _showScrollbars(bool show) { 293 void _showScrollbars(bool show) {
295 if (_hovering == true && _displayOnHover) { 294 if (_hovering == true && _displayOnHover) {
296 show = true; 295 show = true;
297 } 296 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 style.setProperty(cssPos, '${pos}px', ''); 345 style.setProperty(cssPos, '${pos}px', '');
347 if (_cachedSize[cssSize] != size) { 346 if (_cachedSize[cssSize] != size) {
348 _cachedSize[cssSize] = size; 347 _cachedSize[cssSize] = size;
349 style.setProperty(cssSize, '${size}px', ''); 348 style.setProperty(cssSize, '${size}px', '');
350 } 349 }
351 if (element.parent == null) { 350 if (element.parent == null) {
352 _frame.nodes.add(element); 351 _frame.nodes.add(element);
353 } 352 }
354 } 353 }
355 } 354 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/base/base.dart ('k') | samples/swarm/swarm_ui_lib/view/ConveyorView.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698