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

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

Issue 12253011: Reapply remove setInterval. (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 num _timerId; 55 Timer _timer;
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 && _timerId == 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(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 _timerId = window.setTimeout(_boundHideFn, _DISPLAY_TIME); 235 _timer = new Timer(const Duration(milliseconds: _DISPLAY_TIME),
236 _boundHideFn);
236 _scrollInProgress = false; 237 _scrollInProgress = false;
237 } 238 }
238 void onScrollerMoved(num scrollX, num scrollY, bool decelerating) { 239 void onScrollerMoved(num scrollX, num scrollY, bool decelerating) {
239 if (_scrollInProgress == false) { 240 if (_scrollInProgress == false) {
240 // Display the scrollbar and then immediately prepare to hide it... 241 // Display the scrollbar and then immediately prepare to hide it...
241 _onScrollerStart(null); 242 _onScrollerStart(null);
242 _onScrollerEnd(null); 243 _onScrollerEnd(null);
243 } 244 }
244 updateScrollbars(scrollX, scrollY); 245 updateScrollbars(scrollX, scrollY);
245 } 246 }
(...skipping 28 matching lines...) Expand all
274 /** 275 /**
275 * When scrolling starts, show scrollbars and clear hide intervals. 276 * When scrolling starts, show scrollbars and clear hide intervals.
276 */ 277 */
277 void _onScrollerStart(Event e) { 278 void _onScrollerStart(Event e) {
278 _scrollInProgress = true; 279 _scrollInProgress = true;
279 _cancelTimeout(); 280 _cancelTimeout();
280 _showScrollbars(true); 281 _showScrollbars(true);
281 } 282 }
282 283
283 void _cancelTimeout() { 284 void _cancelTimeout() {
284 if (_timerId != null) { 285 if (_timer != null) {
285 window.clearTimeout(_timerId); 286 _timer.cancel();
286 _timerId = null; 287 _timer = null;
287 } 288 }
288 } 289 }
289 290
290 /** 291 /**
291 * Show or hide the scrollbars by changing the opacity. 292 * Show or hide the scrollbars by changing the opacity.
292 */ 293 */
293 void _showScrollbars(bool show) { 294 void _showScrollbars(bool show) {
294 if (_hovering == true && _displayOnHover) { 295 if (_hovering == true && _displayOnHover) {
295 show = true; 296 show = true;
296 } 297 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 style.setProperty(cssPos, '${pos}px', ''); 346 style.setProperty(cssPos, '${pos}px', '');
346 if (_cachedSize[cssSize] != size) { 347 if (_cachedSize[cssSize] != size) {
347 _cachedSize[cssSize] = size; 348 _cachedSize[cssSize] = size;
348 style.setProperty(cssSize, '${size}px', ''); 349 style.setProperty(cssSize, '${size}px', '');
349 } 350 }
350 if (element.parent == null) { 351 if (element.parent == null) {
351 _frame.nodes.add(element); 352 _frame.nodes.add(element);
352 } 353 }
353 } 354 }
354 } 355 }
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