Index: client/base/AnimationScheduler.dart |
=================================================================== |
--- client/base/AnimationScheduler.dart (revision 386) |
+++ client/base/AnimationScheduler.dart (working copy) |
@@ -43,7 +43,7 @@ |
bool _isMobileSafari = false; |
Css _safariHackCss; |
int _frameCount = 0; |
- bool _webkitAnimationFrameMaybeAvailable = true; |
+ bool _animationFrameMaybeAvailable = true; |
AnimationScheduler() |
: _callbacks = new List<CallbackData>() { |
@@ -93,17 +93,35 @@ |
if (USE_INTERVALS) { |
_intervalId = window.setInterval(_step, MS_PER_FRAME); |
} else { |
- if (_webkitAnimationFrameMaybeAvailable) { |
+ if (_animationFrameMaybeAvailable) { |
+ // First try to see if the browser supports the requestAnimationFrame API, |
+ // and if that check fails, fall back to using WebKit/Mozilla/IE specific |
+ // versions of the API. |
try { |
// TODO(jacobr): passing in document should not be required. |
- _intervalId = window.webkitRequestAnimationFrame( |
+ _intervalId = window.requestAnimationFrame( |
Jacob
2011/10/17 18:24:57
This approach would cause multiple exceptions to b
|
(int ignored) { _step(); }, document); |
// TODO(jacobr) fix this odd type error. |
} catch (var e) { |
- _webkitAnimationFrameMaybeAvailable = false; |
+ try { |
+ _intervalId = window.webkitRequestAnimationFrame( |
+ (int ignored) { _step(); }, document); |
+ } catch (var e) { |
+ try { |
Jacob
2011/10/17 18:24:57
at some point, window.mozRequestAnimationFrame mig
|
+ _intervalId = window.mozRequestAnimationFrame( |
+ (int ignored) { _step(); }, document); |
+ } catch (e) { |
+ try { |
+ _intervalId = window.msRequestAnimationFrame( |
+ (int ignored) { _step(); }, document); |
+ } catch (var e) { |
+ _animationFrameMaybeAvailable = false; |
+ } |
+ } |
+ } |
} |
} |
- if (!_webkitAnimationFrameMaybeAvailable) { |
+ if (!_animationFrameMaybeAvailable) { |
_intervalId = window.setTimeout(() { _step(); }, MS_PER_FRAME); |
} |
} |