-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathjquery.requestanimationframe.js
52 lines (44 loc) · 1.12 KB
/
jquery.requestanimationframe.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*!
* jquery.requestanimationframe - 0.2.3-pre
* https://github.com/gnarf37/jquery-requestAnimationFrame
* Requires jQuery 1.8+
*
* Copyright (c) 2016 Corey Frang
* Licensed under the MIT license.
*/
// UMD factory https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} )( function( jQuery ) {
if ( Number( jQuery.fn.jquery.split( "." )[ 0 ] ) >= 3 ) {
if ( window.console && window.console.warn ) {
window.console.warn( "The jquery.requestanimationframe plugin is not needed " +
"in jQuery 3.0 or newer as they handle it natively." );
}
return;
}
var animating;
function raf() {
if ( animating ) {
window.requestAnimationFrame( raf );
jQuery.fx.tick();
}
}
if ( window.requestAnimationFrame ) {
jQuery.fx.timer = function( timer ) {
if ( timer() && jQuery.timers.push( timer ) && !animating ) {
animating = true;
raf();
}
};
jQuery.fx.stop = function() {
animating = false;
};
}
} );