In this question set jquery default animation speed
Someone answered how to set the default animation duration with $.fx.speeds._default = 400;
, and I would really love to know how I'd be able to also set the default easing, and the default queue in the same manor. Can it be done? If so, how?
This has become easy...
Looks like there's been a change with the 2.2 release :
set default easing using jQuery.easing._default
I'll leave the original answer here. I guess the easing plugin may need an update now.
To the first part of the question - default easing isn't as accessible as the animation speed. The part about easing in the jQuery source code doesn't have a default - it is only falling back on a fixed definition of "swing"
in the tween prototype construction. Best approach would probably be to add a small extension to easing (which is accessible globally), much like is done with the special easing equations. Below swing
is redefined/copied as curve
, a default option inside the extension is created and swing
itself (fallback in the prototype) is used to reflect the new variable default property :
$.easing['curve'] = $.easing['swing'];
$.extend($.easing, {
default: 'curve',
swing: function(x, t, b, c, d) {
return $.easing[$.easing.default](x, t, b, c, d);
}
});
Now inside whatever function you're writing up, the default can be set :
$.easing.default = 'linear';
At the basic level only two types are available of course, linear
and curve
(formerly swing
).
http://codepen.io/anon/pen/aOOMPV?editors=001
If you want to use the special plugin, it would be written like this by the way :
$.easing.def = 'linear';
Using swing
is then jswing
(a term I'm not a big fan of, unlike the plugin) but you could slightly rewrite that of course (like I usually do).
Maybe you could elaborate on the second part of the question? Very plainly, this would qualify (the standard effects queue) but I assume that is not what you're after :
$.fx.off = !$.fx.off;