forked from mgcrea/angular-strap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraf.js
More file actions
29 lines (28 loc) · 1.11 KB
/
raf.js
File metadata and controls
29 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* angular-strap
* @version v2.3.8 - 2016-03-31
* @link http://mgcrea.github.io/angular-strap
* @author Olivier Louvignes <olivier@mg-crea.com> (https://github.com/mgcrea)
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
'use strict';
if (angular.version.minor < 3 && angular.version.dot < 14) {
angular.module('ng').factory('$$rAF', [ '$window', '$timeout', function($window, $timeout) {
var requestAnimationFrame = $window.requestAnimationFrame || $window.webkitRequestAnimationFrame || $window.mozRequestAnimationFrame;
var cancelAnimationFrame = $window.cancelAnimationFrame || $window.webkitCancelAnimationFrame || $window.mozCancelAnimationFrame || $window.webkitCancelRequestAnimationFrame;
var rafSupported = !!requestAnimationFrame;
var raf = rafSupported ? function(fn) {
var id = requestAnimationFrame(fn);
return function() {
cancelAnimationFrame(id);
};
} : function(fn) {
var timer = $timeout(fn, 16.66, false);
return function() {
$timeout.cancel(timer);
};
};
raf.supported = rafSupported;
return raf;
} ]);
}