diff options
| author | Matias Niemelä | 2014-02-24 18:14:29 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-02-24 21:23:05 -0500 |
| commit | 04d7317cdd95ba00783389f89f6e9a7e1fc418f8 (patch) | |
| tree | c0eff0f1d143a3340c40b532a3ffd4149787d0a0 /src/ng | |
| parent | 2cd87dbb93497e38ffad016c1f5766c2bb56e604 (diff) | |
| download | angular.js-04d7317cdd95ba00783389f89f6e9a7e1fc418f8.tar.bz2 | |
chore(core): introduce a wrapper for requestAnimationFrame
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/raf.js | 22 |
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; + }]; +} |
