Skip to content

Commit 3c486d1

Browse files
committed
Drop unneeded polyfill & Firefox prefix.
1 parent d796ee9 commit 3c486d1

File tree

3 files changed

+7
-65
lines changed

3 files changed

+7
-65
lines changed

dist/jquery.requestAnimationFrame.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*! jQuery requestAnimationFrame - v0.1.3pre - 2013-04-15
1+
/*! jQuery requestAnimationFrame - v0.1.3pre - 2014-02-02
22
* https://github.com/gnarf37/jquery-requestAnimationFrame
3-
* Copyright (c) 2013 Corey Frang; Licensed MIT */
3+
* Copyright (c) 2014 Corey Frang; Licensed MIT */
44

55
(function( $ ) {
66

@@ -11,17 +11,7 @@
1111

1212

1313
var animating,
14-
lastTime = 0,
15-
vendors = ['webkit', 'moz'],
16-
requestAnimationFrame = window.requestAnimationFrame,
17-
cancelAnimationFrame = window.cancelAnimationFrame;
18-
19-
for(; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
20-
requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ];
21-
cancelAnimationFrame = cancelAnimationFrame ||
22-
window[ vendors[lastTime] + "CancelAnimationFrame" ] ||
23-
window[ vendors[lastTime] + "CancelRequestAnimationFrame" ];
24-
}
14+
requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame;
2515

2616
function raf() {
2717
if ( animating ) {
@@ -31,9 +21,6 @@ function raf() {
3121
}
3222

3323
if ( requestAnimationFrame ) {
34-
// use rAF
35-
window.requestAnimationFrame = requestAnimationFrame;
36-
window.cancelAnimationFrame = cancelAnimationFrame;
3724
jQuery.fx.timer = function( timer ) {
3825
if ( timer() && jQuery.timers.push( timer ) && !animating ) {
3926
animating = true;
@@ -44,22 +31,6 @@ if ( requestAnimationFrame ) {
4431
jQuery.fx.stop = function() {
4532
animating = false;
4633
};
47-
} else {
48-
// polyfill
49-
window.requestAnimationFrame = function( callback, element ) {
50-
var currTime = new Date().getTime(),
51-
timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ),
52-
id = window.setTimeout( function() {
53-
callback( currTime + timeToCall );
54-
}, timeToCall );
55-
lastTime = currTime + timeToCall;
56-
return id;
57-
};
58-
59-
window.cancelAnimationFrame = function(id) {
60-
clearTimeout(id);
61-
};
62-
6334
}
6435

6536
}( jQuery ));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery requestAnimationFrame - v0.1.3pre - 2013-04-15
1+
/*! jQuery requestAnimationFrame - v0.1.3pre - 2014-02-02
22
* https://github.com/gnarf37/jquery-requestAnimationFrame
3-
* Copyright (c) 2013 Corey Frang; Licensed MIT */
4-
(function(e){function o(){t&&(i(o),jQuery.fx.tick())}var t,n=0,r=["webkit","moz"],i=window.requestAnimationFrame,s=window.cancelAnimationFrame;for(;n<r.length&&!i;n++)i=window[r[n]+"RequestAnimationFrame"],s=s||window[r[n]+"CancelAnimationFrame"]||window[r[n]+"CancelRequestAnimationFrame"];i?(window.requestAnimationFrame=i,window.cancelAnimationFrame=s,jQuery.fx.timer=function(e){e()&&jQuery.timers.push(e)&&!t&&(t=!0,o())},jQuery.fx.stop=function(){t=!1}):(window.requestAnimationFrame=function(e,t){var r=(new Date).getTime(),i=Math.max(0,16-(r-n)),s=window.setTimeout(function(){e(r+i)},i);return n=r+i,s},window.cancelAnimationFrame=function(e){clearTimeout(e)})})(jQuery);
3+
* Copyright (c) 2014 Corey Frang; Licensed MIT */
4+
(function(e){function r(){t&&(n(r),jQuery.fx.tick())}var t,n=window.requestAnimationFrame||window.webkitRequestAnimationFrame;n&&(jQuery.fx.timer=function(e){e()&&jQuery.timers.push(e)&&!t&&(t=!0,r())},jQuery.fx.stop=function(){t=!1})})(jQuery);

src/jquery.requestAnimationFrame.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,7 @@
1616

1717

1818
var animating,
19-
lastTime = 0,
20-
vendors = ['webkit', 'moz'],
21-
requestAnimationFrame = window.requestAnimationFrame,
22-
cancelAnimationFrame = window.cancelAnimationFrame;
23-
24-
for(; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
25-
requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ];
26-
cancelAnimationFrame = cancelAnimationFrame ||
27-
window[ vendors[lastTime] + "CancelAnimationFrame" ] ||
28-
window[ vendors[lastTime] + "CancelRequestAnimationFrame" ];
29-
}
19+
requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame;
3020

3121
function raf() {
3222
if ( animating ) {
@@ -36,9 +26,6 @@ function raf() {
3626
}
3727

3828
if ( requestAnimationFrame ) {
39-
// use rAF
40-
window.requestAnimationFrame = requestAnimationFrame;
41-
window.cancelAnimationFrame = cancelAnimationFrame;
4229
jQuery.fx.timer = function( timer ) {
4330
if ( timer() && jQuery.timers.push( timer ) && !animating ) {
4431
animating = true;
@@ -49,22 +36,6 @@ if ( requestAnimationFrame ) {
4936
jQuery.fx.stop = function() {
5037
animating = false;
5138
};
52-
} else {
53-
// polyfill
54-
window.requestAnimationFrame = function( callback, element ) {
55-
var currTime = new Date().getTime(),
56-
timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ),
57-
id = window.setTimeout( function() {
58-
callback( currTime + timeToCall );
59-
}, timeToCall );
60-
lastTime = currTime + timeToCall;
61-
return id;
62-
};
63-
64-
window.cancelAnimationFrame = function(id) {
65-
clearTimeout(id);
66-
};
67-
6839
}
6940

7041
}( jQuery ));

0 commit comments

Comments
 (0)