| Total Complexity | 7 |
| Complexity/F | 1.75 |
| Lines of Code | 23 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | // make sure requestAnimationFrame and cancelAnimationFrame are defined |
||
| 4 | (function () { |
||
| 5 | var lastTime = 0; |
||
| 6 | var vendors = ['webkit', 'moz', 'ms', 'o']; |
||
| 7 | for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { |
||
| 8 | window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; |
||
| 9 | window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || |
||
| 10 | window[vendors[x] + 'CancelRequestAnimationFrame']; |
||
| 11 | } |
||
| 12 | if (!window.requestAnimationFrame) { |
||
| 13 | window.requestAnimationFrame = function (callback) { |
||
| 14 | var currTime = new Date().getTime(); |
||
| 15 | var timeToCall = Math.max(0, 16 - (currTime - lastTime)); |
||
| 16 | var id = window.setTimeout(function () { return callback(currTime + timeToCall); }, timeToCall); |
||
| 17 | lastTime = currTime + timeToCall; |
||
| 18 | return id; |
||
| 19 | }; |
||
| 20 | } |
||
| 21 | if (!window.cancelAnimationFrame) { |
||
| 22 | window.cancelAnimationFrame = function (id) { |
||
| 23 | clearTimeout(id); |
||
| 24 | }; |
||
| 25 | } |
||
| 26 | })(); |
||
| 27 |