set jquery default animation speed

后端 未结 2 1624
天涯浪人
天涯浪人 2021-02-14 04:00

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

 $.setDefaultAnimationSpeed = 5000; //does not wor         


        
相关标签:
2条回答
  • 2021-02-14 04:45

    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.

    0 讨论(0)
  • 2021-02-14 04:48
    $.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

    0 讨论(0)
提交回复
热议问题