// Start an animation from one number to another
custom: function( from, to, unit ) {
var self = this,
- fx = jQuery.fx;
+ fx = jQuery.fx,
+ raf;
this.startTime = jQuery.now();
this.start = from;
// Use requestAnimationFrame instead of setInterval if available
if ( requestAnimationFrame ) {
timerId = 1;
- requestAnimationFrame(function raf() {
+ raf = function() {
// When timerId gets set to null at any point, this stops
if ( timerId ) {
requestAnimationFrame( raf );
fx.tick();
}
- });
+ };
+ requestAnimationFrame( raf );
} else {
timerId = setInterval( fx.tick, fx.interval );
}