@@ -99,3 +99,38 @@ if (!window.console.log) window.console.log = function () { };
9999if ( ! window . console . error ) window . console . error = function ( ) { } ;
100100if ( ! window . console . warn ) window . console . warn = function ( ) { } ;
101101if ( ! window . console . assert ) window . console . assert = function ( ) { } ;
102+
103+ //RequestAnimationFrame (IE9, Android 4.1, 4.2, 4.3)
104+ /*! @author Paul Irish */
105+ /*! @source https://gist.github.com/paulirish/1579671 */
106+ // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
107+ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
108+
109+ // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
110+
111+ // MIT license
112+
113+ ( function ( ) {
114+ var lastTime = 0 ;
115+ var vendors = [ 'ms' , 'moz' , 'webkit' , 'o' ] ;
116+ for ( var x = 0 ; x < vendors . length && ! window . requestAnimationFrame ; ++ x ) {
117+ window . requestAnimationFrame = window [ vendors [ x ] + 'RequestAnimationFrame' ] ;
118+ window . cancelAnimationFrame = window [ vendors [ x ] + 'CancelAnimationFrame' ]
119+ || window [ vendors [ x ] + 'CancelRequestAnimationFrame' ] ;
120+ }
121+
122+ if ( ! window . requestAnimationFrame )
123+ window . requestAnimationFrame = function ( callback , element ) {
124+ var currTime = new Date ( ) . getTime ( ) ;
125+ var timeToCall = Math . max ( 0 , 16 - ( currTime - lastTime ) ) ;
126+ var id = window . setTimeout ( function ( ) { callback ( currTime + timeToCall ) ; } ,
127+ timeToCall ) ;
128+ lastTime = currTime + timeToCall ;
129+ return id ;
130+ } ;
131+
132+ if ( ! window . cancelAnimationFrame )
133+ window . cancelAnimationFrame = function ( id ) {
134+ clearTimeout ( id ) ;
135+ } ;
136+ } ( ) ) ;
0 commit comments