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

Side by Side Diff: packages/charted/lib/core/timer.dart

Issue 2213693002: Updated charted DEP to 0.4.X (Closed) Base URL: https://github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // 1 //
2 // Copyright 2014 Google Inc. All rights reserved. 2 // Copyright 2014 Google Inc. All rights reserved.
3 // 3 //
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at 5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd 6 // https://developers.google.com/open-source/licenses/bsd
7 // 7 //
8 8
9 /// A [window.requestAnimationFrame] based timer for use with transitions. 9 /// A [window.requestAnimationFrame] based timer for use with transitions.
10 /// Uses [dart.async.Timer] when the time until next timeout is too long. 10 /// Uses [dart.async.Timer] when the time until next timeout is too long.
11 library charted.core.timer; 11 library charted.core.timer;
12 12
13 import 'dart:async'; 13 import 'dart:async';
14 import 'dart:html' show window; 14 import 'dart:html' show window;
15 import 'dart:collection'; 15 import 'dart:collection';
16 16
17 typedef bool TimerCallback(int time); 17 typedef bool TimerCallback(int time);
18 18
19 class AnimationTimer extends LinkedListEntry { 19 class AnimationTimer extends LinkedListEntry<AnimationTimer> {
20 static LinkedList<AnimationTimer> _queue = new LinkedList<AnimationTimer>(); 20 static LinkedList<AnimationTimer> _queue = new LinkedList<AnimationTimer>();
21 21
22 /// true if we are already waiting for window.animationFrame. At any given 22 /// true if we are already waiting for window.animationFrame. At any given
23 /// time, only one of _timerScheduled and _animationFrameRequested are set 23 /// time, only one of _timerScheduled and _animationFrameRequested are set
24 static bool _animationFrameRequested = false; 24 static bool _animationFrameRequested = false;
25 25
26 /// Instance of currently scheduled timer. At any given time, only one 26 /// Instance of currently scheduled timer. At any given time, only one
27 /// of _timerScheduled and _animationFrameRequested are set. 27 /// of _timerScheduled and _animationFrameRequested are set.
28 static Timer _timerScheduled; 28 static Timer _timerScheduled;
29 29
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 earliest = timer.time; 71 earliest = timer.time;
72 } 72 }
73 timer = timer.next; 73 timer = timer.next;
74 if (finished) ref.unlink(); 74 if (finished) ref.unlink();
75 } 75 }
76 active = null; 76 active = null;
77 return earliest == null ? earliest : earliest - now; 77 return earliest == null ? earliest : earliest - now;
78 } 78 }
79 79
80 /// Internal timer and animation frame handler. 80 /// Internal timer and animation frame handler.
81 _step([_]) { 81 _step([num _]) {
82 int delay = flush(); 82 int delay = flush();
83 83
84 if (delay == null) { 84 if (delay == null) {
85 _animationFrameRequested = false; 85 _animationFrameRequested = false;
86 } else if (delay > 24) { 86 } else if (delay > 24) {
87 if (_timerScheduled != null) { 87 if (_timerScheduled != null) {
88 _timerScheduled.cancel(); 88 _timerScheduled.cancel();
89 } 89 }
90 _timerScheduled = new Timer(new Duration(milliseconds: delay), _step); 90 _timerScheduled = new Timer(new Duration(milliseconds: delay), _step);
91 _animationFrameRequested = false; 91 _animationFrameRequested = false;
92 } else { 92 } else {
93 _animationFrameRequested = true; 93 _animationFrameRequested = true;
94 window.animationFrame.then(_step); 94 window.animationFrame.then(_step);
95 } 95 }
96 } 96 }
97 } 97 }
OLDNEW
« no previous file with comments | « packages/charted/lib/core/text_metrics/segmentation.dart ('k') | packages/charted/lib/core/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698