6

I know the frame rate in jQuery could be set through jQuery.fx.interval. However, it applies to all the jQuery internal animate function such as slideDown, fadeIn and animateetc.

I want to set frame rate for each animate(), how could I archieve that?

vcsjones
  • 138,677
  • 31
  • 291
  • 286
steveyang
  • 9,178
  • 8
  • 54
  • 80

2 Answers2

1

From the API documentation page:

Since jQuery uses one global interval, no animation should be running or all animations should stop for the change of this property to take effect.

Note: jQuery.fx.interval currently has no effect in browsers that support the requestAnimationFrame property, such as Google Chrome 11. This behavior is subject to change in a future release.

I take from this that you cannot set the frame rate for an individual animate call, unless you were willing to have no animations until that one had completed, and even then you can't guarantee the behaviour. It's probably best to leave the setting alone.

Community
  • 1
  • 1
lonesomeday
  • 233,373
  • 50
  • 316
  • 318
  • So to clarify, jQuery uses something like this: `window.setInterval(incrementAllAnimations, jQuery.fx.interval) ` so it's just not possible to change it. – Nathan MacInnes Nov 21 '11 at 13:25
  • @NathanMacInnes [Yes, almost exactly.](https://github.com/jquery/jquery/blob/master/src/effects.js#L457) – lonesomeday Nov 21 '11 at 18:04
0

You can change this by using fx.interval. Like this:

jQuery.fx.interval = 100;

$("input").click(function(){
  $("div").toggle( 3000 );
});

Although it says in the documentation that:

jQuery.fx.interval currently has no effect in browsers that support the requestAnimationFrame property, such as Google Chrome 11. This behavior is subject to change in a future release.

Jan Dragsbaek
  • 8,078
  • 2
  • 26
  • 46
  • I already stated it in my post. I want to set 'per animate' frame rate. This answer is irrelevant to this question. – steveyang Nov 21 '11 at 10:08
  • But if you make the change directly before you call the particular animate, you can sort of do this. I think you're out of luck if you have multiple animations running at once, however. – Nicole Stein Jun 27 '13 at 21:39