From 147478cdf136baef9d78452be82914e24689b300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Sun, 2 Feb 2014 18:52:40 +0100 Subject: [PATCH] Drop unneeded polyfill & prefixes --- dist/jquery.requestAnimationFrame.js | 46 +++++------------------- dist/jquery.requestAnimationFrame.min.js | 6 ++-- src/jquery.requestAnimationFrame.js | 36 ++----------------- 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/dist/jquery.requestAnimationFrame.js b/dist/jquery.requestAnimationFrame.js index 977bd88..7858ea1 100644 --- a/dist/jquery.requestAnimationFrame.js +++ b/dist/jquery.requestAnimationFrame.js @@ -1,16 +1,16 @@ -/*! jQuery requestAnimationFrame - v0.1.3pre - 2015-04-27 +/*! jQuery requestAnimationFrame - v0.1.3pre - 2016-02-03 * https://github.com/gnarf37/jquery-requestAnimationFrame -* Copyright (c) 2015 Corey Frang; Licensed MIT */ +* Copyright (c) 2016 Corey Frang; Licensed MIT */ // UMD factory https://github.com/umdjs/umd/blob/master/jqueryPlugin.js (function (factory) { - if (typeof define === 'function' && define.amd) { + if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); - } else { + } else { // Browser globals factory(jQuery); - } + } }(function (jQuery) { // requestAnimationFrame polyfill adapted from Erik Möller @@ -19,30 +19,16 @@ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating -var animating, - lastTime = 0, - vendors = ['webkit', 'moz'], - requestAnimationFrame = window.requestAnimationFrame, - cancelAnimationFrame = window.cancelAnimationFrame; - -for(; lastTime < vendors.length && !requestAnimationFrame; lastTime++) { - requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ]; - cancelAnimationFrame = cancelAnimationFrame || - window[ vendors[lastTime] + "CancelAnimationFrame" ] || - window[ vendors[lastTime] + "CancelRequestAnimationFrame" ]; -} +var animating; function raf() { if ( animating ) { - requestAnimationFrame( raf ); + window.requestAnimationFrame( raf ); jQuery.fx.tick(); } } -if ( requestAnimationFrame ) { - // use rAF - window.requestAnimationFrame = requestAnimationFrame; - window.cancelAnimationFrame = cancelAnimationFrame; +if ( window.requestAnimationFrame ) { jQuery.fx.timer = function( timer ) { if ( timer() && jQuery.timers.push( timer ) && !animating ) { animating = true; @@ -53,22 +39,6 @@ if ( requestAnimationFrame ) { jQuery.fx.stop = function() { animating = false; }; -} else { - // polyfill - window.requestAnimationFrame = function( callback, element ) { - var currTime = new Date().getTime(), - timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ), - id = window.setTimeout( function() { - callback( currTime + timeToCall ); - }, timeToCall ); - lastTime = currTime + timeToCall; - return id; - }; - - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - } })); diff --git a/dist/jquery.requestAnimationFrame.min.js b/dist/jquery.requestAnimationFrame.min.js index f178b52..a0912ae 100644 --- a/dist/jquery.requestAnimationFrame.min.js +++ b/dist/jquery.requestAnimationFrame.min.js @@ -1,4 +1,4 @@ -/*! jQuery requestAnimationFrame - v0.1.3pre - 2015-04-27 +/*! jQuery requestAnimationFrame - v0.1.3pre - 2016-02-03 * https://github.com/gnarf37/jquery-requestAnimationFrame -* Copyright (c) 2015 Corey Frang; Licensed MIT */ -(function(e){typeof define=="function"&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function o(){t&&(i(o),e.fx.tick())}var t,n=0,r=["webkit","moz"],i=window.requestAnimationFrame,s=window.cancelAnimationFrame;for(;n