Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First Draft

  • Loading branch information...
commit b685faee964a6071a271aa1123d463482e62cb6d 1 parent a3165cc
@gnarf authored
View
27 dist/jquery.requestAnimationFrame.js
@@ -4,4 +4,31 @@
(function( $ ) {
+var animating,
+ requestAnimationFrame = window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame;
+
+function raf() {
+ if ( animating ) {
+ requestAnimationFrame( raf );
+ jQuery.fx.tick();
+ }
+}
+
+if ( requestAnimationFrame ) {
+
+ jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) && !animating ) {
+ animating = true;
+ raf();
+ }
+ };
+
+ jQuery.fx.stop = function() {
+ animating = false;
+ };
+
+}
+
}( jQuery ));
View
2  dist/jquery.requestAnimationFrame.min.js
@@ -1,4 +1,4 @@
/*! jQuery requestAnimationFrame - v0.0.0 - 2012-08-09
* https://github.com/gnarf37/jquery-requestAnimationFrame
* Copyright (c) 2012 Corey Frang; Licensed MIT */
-(function(a){})(jQuery);
+(function(a){function d(){b&&(c(d),jQuery.fx.tick())}var b,c=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame;c&&(jQuery.fx.timer=function(a){a()&&jQuery.timers.push(a)&&!b&&(b=!0,d())},jQuery.fx.stop=function(){b=!1})})(jQuery);
View
6,823 libs/jquery/jquery.js
3,323 additions, 3,500 deletions not shown
View
28 src/jquery.requestAnimationFrame.js
@@ -1,6 +1,7 @@
/*
* jquery.requestAnimationFrame
* https://github.com/gnarf37/jquery-requestAnimationFrame
+ * Requires jQuery 1.8+
*
* Copyright (c) 2012 Corey Frang
* Licensed under the MIT license.
@@ -8,4 +9,31 @@
(function( $ ) {
+var animating,
+ requestAnimationFrame = window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame;
+
+function raf() {
+ if ( animating ) {
+ requestAnimationFrame( raf );
+ jQuery.fx.tick();
+ }
+}
+
+if ( requestAnimationFrame ) {
+
+ jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) && !animating ) {
+ animating = true;
+ raf();
+ }
+ };
+
+ jQuery.fx.stop = function() {
+ animating = false;
+ };
+
+}
+
}( jQuery ));
View
14 test/jquery.requestAnimationFrame_test.js
@@ -3,6 +3,18 @@
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
(function($) {
- module('jQuery.requestAnimationFrame');
+ module('jQuery.requestAnimationFrame');
+
+ asyncTest( "Animations still work", 1, function() {
+ jQuery( "<div>" ).appendTo( "#qunit-fixture" ).animate({
+ width: 80
+ },{
+ duration: 100,
+ complete: function() {
+ equal( jQuery( this ).width(), 80, "Width is 80" );
+ start();
+ }
+ });
+ });
}(jQuery));
Please sign in to comment.
Something went wrong with that request. Please try again.