11

I cannot find any documentation. All I want to do it set jQuerys default animation speed. Something like this:

 $.setDefaultAnimationSpeed = 5000; //does not work

 $('elem').fadeIn(); // takes 5 seconds
 $('elem').animate({
     foo : bar
 }); // also takes 5 seconds

Thanks folks!

Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
  • I wrote a dumby command. $.setDefaultAnimationSpeed is not a real thing. – Fresheyeball Feb 13 '12 at 05:51
  • Trying to set $.setDefaultAnimationSpeed doesn't work because jQuery's default animation speed doesn't trigger off such a property (nor any property for that matter that I know of). Instead, you should use the method @dku.rajkumar has provided as it is the most commonly used method of setting a "global" animation speed that you can use throughout your jQuery script. – seeming.amusing Feb 13 '12 at 06:04

2 Answers2

32
$.fx.speeds._default = 1000; // change to whatever your desired speed

or

$.fx.speeds.jojo = 1000; // adds your own speed object to jqueryspeed

Reference: https://learn.jquery.com/effects/intro-to-effects/#jquery-fx

Pang
  • 9,564
  • 146
  • 81
  • 122
jojo
  • 336
  • 2
  • 2
-2

i dont think there is any such thing in jquery but you can try something like this

 defaultAnimationSpeed = 5000;  // declare a global variable

 $('elem').fadeIn(defaultAnimationSpeed); 
 $('elem').animate({foo : bar}, defaultAnimationSpeed);

So that it will be applicable wherever it is used and also you can change it very easily. you need not change everywhere in animation.

dku.rajkumar
  • 18,414
  • 7
  • 41
  • 58