I have written a plugin with the following "signature":
jQuery.fn.attach = function(element, settings, duration, options, callback) {
Here element
is a jQuery object, settings
are my custom settings for my plugin and duration
, options
and callback
are all parameters that I use in jQuery's animate, like this:
someObject.animate({ someCSS }, duration, options, callback);
Now, my question is: Is it possible to make this function easier to call? For instance, right now, to get everything to work as I expect... I have to include all parameters and set the parameters that I don't use to null
:
$(this).attach($('#e1-blue'), null, 3000, null, function() { alert('done'); });
It would be nice to also be able to call this as:
$(this).attach($('#e1-blue'), 3000, function() { alert('done'); });
and as this (ofc)...
$(this).attach($('#e1-blue'), 3000);
Any suggestions?