main
js 36 lines 1.25 KB
Raw
1 import 'core-js/es6/symbol';
2 import 'core-js/es6/promise';
3 import 'core-js/es6/set';
4 import 'core-js/es6/map';
5
6 // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
7 // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
8
9 // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
10 // MIT license
11 (function () {
12 var lastTime = 0;
13 var vendors = ['ms', 'moz', 'webkit', 'o'];
14 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
15 window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
16 window.cancelAnimationFrame =
17 window[vendors[x] + 'CancelAnimationFrame'] ||
18 window[vendors[x] + 'CancelRequestAnimationFrame'];
19 }
20
21 if (!window.requestAnimationFrame)
22 window.requestAnimationFrame = function (callback, element) {
23 var currTime = new Date().getTime();
24 var timeToCall = Math.max(0, 16 - (currTime - lastTime));
25 var id = window.setTimeout(function () {
26 callback(currTime + timeToCall);
27 }, timeToCall);
28 lastTime = currTime + timeToCall;
29 return id;
30 };
31
32 if (!window.cancelAnimationFrame)
33 window.cancelAnimationFrame = function (id) {
34 clearTimeout(id);
35 };
36 })();