aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/raf.js
diff options
context:
space:
mode:
authorMatias Niemelä2014-02-24 18:14:29 -0500
committerMatias Niemelä2014-02-24 21:23:05 -0500
commit04d7317cdd95ba00783389f89f6e9a7e1fc418f8 (patch)
treec0eff0f1d143a3340c40b532a3ffd4149787d0a0 /src/ng/raf.js
parent2cd87dbb93497e38ffad016c1f5766c2bb56e604 (diff)
downloadangular.js-04d7317cdd95ba00783389f89f6e9a7e1fc418f8.tar.bz2
chore(core): introduce a wrapper for requestAnimationFrame
Diffstat (limited to 'src/ng/raf.js')
-rw-r--r--src/ng/raf.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ng/raf.js b/src/ng/raf.js
new file mode 100644
index 00000000..f85ee12a
--- /dev/null
+++ b/src/ng/raf.js
@@ -0,0 +1,22 @@
+'use strict';
+
+function $$RAFProvider(){ //rAF
+ this.$get = ['$window', function($window) {
+ var requestAnimationFrame = $window.requestAnimationFrame ||
+ $window.webkitRequestAnimationFrame;
+
+ var cancelAnimationFrame = $window.cancelAnimationFrame ||
+ $window.webkitCancelAnimationFrame;
+
+ var raf = function(fn) {
+ var id = requestAnimationFrame(fn);
+ return function() {
+ cancelAnimationFrame(id);
+ };
+ };
+
+ raf.supported = !!requestAnimationFrame;
+
+ return raf;
+ }];
+}