forked from jeromeetienne/threex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
THREEx.requestAnimationFrame.js
38 lines (26 loc) · 1018 Bytes
/
THREEx.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
/**
* Provides requestAnimationFrame/cancelRequestAnimation in a cross browser way.
* from paul irish + jerome etienne
* - http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* - http://notes.jetienne.com/2011/05/18/cancelRequestAnimFrame-for-paul-irish-requestAnimFrame.html
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
return window.setTimeout( callback, 1000 / 60 );
};
} )();
}
if ( !window.cancelRequestAnimationFrame ) {
window.cancelRequestAnimationFrame = ( function() {
return window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout
} )();
}