|
9 | 9 | // MIT license
|
10 | 10 |
|
11 | 11 | (function() {
|
12 |
| -'use strict'; |
| 12 | + 'use strict'; |
13 | 13 |
|
14 |
| -if (!Date.now) { |
15 |
| - /** |
16 |
| - * Date.now polyfill. |
17 |
| - * @return {number} the current Date |
18 |
| - */ |
19 |
| - Date.now = function() { return new Date().getTime(); }; |
20 |
| - Date['now'] = Date.now; |
21 |
| -} |
| 14 | + if (!Date.now) { |
| 15 | + /** |
| 16 | + * Date.now polyfill. |
| 17 | + * @return {number} the current Date |
| 18 | + */ |
| 19 | + Date.now = function() { return new Date().getTime(); }; |
| 20 | + Date['now'] = Date.now; |
| 21 | + } |
22 | 22 |
|
23 |
| -var vendors = ['webkit', 'moz']; |
24 |
| -for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { |
25 |
| - var vp = vendors[i]; |
26 |
| - window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; |
27 |
| - window.cancelAnimationFrame = (window[vp + 'CancelAnimationFrame'] || |
28 |
| - window[vp + 'CancelRequestAnimationFrame']); |
29 |
| - window['requestAnimationFrame'] = window.requestAnimationFrame; |
30 |
| - window['cancelAnimationFrame'] = window.cancelAnimationFrame; |
31 |
| -} |
| 23 | + var vendors = ['webkit', 'moz']; |
| 24 | + for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { |
| 25 | + var vp = vendors[i]; |
| 26 | + window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; |
| 27 | + window.cancelAnimationFrame = (window[vp + 'CancelAnimationFrame'] || |
| 28 | + window[vp + 'CancelRequestAnimationFrame']); |
| 29 | + window['requestAnimationFrame'] = window.requestAnimationFrame; |
| 30 | + window['cancelAnimationFrame'] = window.cancelAnimationFrame; |
| 31 | + } |
32 | 32 |
|
33 |
| -if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { |
34 |
| - var lastTime = 0; |
35 |
| - /** |
36 |
| - * requestAnimationFrame polyfill. |
37 |
| - * @param {!Function} callback the callback function. |
38 |
| - */ |
39 |
| - window.requestAnimationFrame = function(callback) { |
40 |
| - var now = Date.now(); |
41 |
| - var nextTime = Math.max(lastTime + 16, now); |
42 |
| - return setTimeout(function() { callback(lastTime = nextTime); }, |
43 |
| - nextTime - now); |
44 |
| - }; |
45 |
| - window.cancelAnimationFrame = clearTimeout; |
46 |
| - window['requestAnimationFrame'] = window.requestAnimationFrame; |
47 |
| - window['cancelAnimationFrame'] = window.cancelAnimationFrame; |
48 |
| -} |
| 33 | + if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { |
| 34 | + var lastTime = 0; |
| 35 | + /** |
| 36 | + * requestAnimationFrame polyfill. |
| 37 | + * @param {!Function} callback the callback function. |
| 38 | + */ |
| 39 | + window.requestAnimationFrame = function(callback) { |
| 40 | + var now = Date.now(); |
| 41 | + var nextTime = Math.max(lastTime + 16, now); |
| 42 | + return setTimeout(function() { callback(lastTime = nextTime); }, |
| 43 | + nextTime - now); |
| 44 | + }; |
| 45 | + window.cancelAnimationFrame = clearTimeout; |
| 46 | + window['requestAnimationFrame'] = window.requestAnimationFrame; |
| 47 | + window['cancelAnimationFrame'] = window.cancelAnimationFrame; |
| 48 | + } |
49 | 49 |
|
50 | 50 | })();
|
0 commit comments