Allow plugin user to enter their own function as an option to the plugin itself?
I'm creating a plugin that, by default, is a type of image/content slider. I've been using this code in a couple of projects and find that if I make a couple changes to a piece of the code, it can be much more than a plain slider.
Basically, there are two lines of code that contain an animation: one for the outgoing image, and one for the incoming image. I'd like to have default animations for users that want to keep the general functionality, but would also like more experienced users to be able to input their own animations if they'd like to make it a bit more interesting.
The catch, and my questions, is am I able to allow users to provide an animation or function through an option of the plugin so that they don't have to modify the original code?
Here is one of the lines in question:
- $('.current').removeClass('current').animate({left: -(parentWidth + 50)}, options.speed, function(){$(this).css({'display':'none'})}).animate({left: (parentWidth + 50)},0);
I'd like to keep the selector and removeClass there no matter what, but allow the user to essentially replace everything after as an option. Can this be done?
The previous code is from the plugin version that I am currently working on. you may see a working example (not in plugin form) here:
http://mattsolano.com/ps2/ Line 241 is where I start really adjusting the animation
Thanks