Extending slider prototype. Override any function

Sometimes you need to do something when slider does something, and there are no public event for this. If you don't wish to modify slider core, you may extend it's prototype.

Let's assume that you need to know when slider autoplay has stopped permanently. There is public function stopAutoPlay, let's extend it.

jQuery(document).ready(function($) {
    // initialize slider as usual and save it's object
    var slider = $('.royalSlider').royalSlider({
        // options
    }).data('royalSlider');

    // extend slider object
    slider.stopAutoPlay = function( /* optional_arguments */  ) {
        // do something there    
        console.log('slideshow is permanently stopped');

        $.rsProto.stopAutoPlay.call(this /* , optional_arguments */ );
    };

});

jQuery.rsProto - public variable that holds slider prototype, log it to see what functions do you have.

You can extend only public functions. Functions that start from underscore _ get renamed by my js compiler, so in packed version they will have different name.
But, if you use unminified version of script, you can extend these private functions too.


Found a mistake in article? Know how to improve it? Please open support ticket.