Skip to content

Commit 5e406f7

Browse files
committed
Drop unneeded polyfill & prefixes
1 parent 0b82fcc commit 5e406f7

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/jquery.requestAnimationFrame.js

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,16 @@
2323
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
2424

2525

26-
var animating,
27-
lastTime = 0,
28-
vendors = ['webkit', 'moz'],
29-
requestAnimationFrame = window.requestAnimationFrame,
30-
cancelAnimationFrame = window.cancelAnimationFrame;
31-
32-
for(; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
33-
requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ];
34-
cancelAnimationFrame = cancelAnimationFrame ||
35-
window[ vendors[lastTime] + "CancelAnimationFrame" ] ||
36-
window[ vendors[lastTime] + "CancelRequestAnimationFrame" ];
37-
}
26+
var animating;
3827

3928
function raf() {
4029
if ( animating ) {
41-
requestAnimationFrame( raf );
30+
window.requestAnimationFrame( raf );
4231
jQuery.fx.tick();
4332
}
4433
}
4534

46-
if ( requestAnimationFrame ) {
47-
// use rAF
48-
window.requestAnimationFrame = requestAnimationFrame;
49-
window.cancelAnimationFrame = cancelAnimationFrame;
35+
if ( window.requestAnimationFrame ) {
5036
jQuery.fx.timer = function( timer ) {
5137
if ( timer() && jQuery.timers.push( timer ) && !animating ) {
5238
animating = true;
@@ -57,22 +43,6 @@ if ( requestAnimationFrame ) {
5743
jQuery.fx.stop = function() {
5844
animating = false;
5945
};
60-
} else {
61-
// polyfill
62-
window.requestAnimationFrame = function( callback, element ) {
63-
var currTime = new Date().getTime(),
64-
timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ),
65-
id = window.setTimeout( function() {
66-
callback( currTime + timeToCall );
67-
}, timeToCall );
68-
lastTime = currTime + timeToCall;
69-
return id;
70-
};
71-
72-
window.cancelAnimationFrame = function(id) {
73-
clearTimeout(id);
74-
};
75-
7646
}
7747

7848
}));

0 commit comments

Comments
 (0)