Skip to content

Instantly share code, notes, and snippets.

@theMikeD
Last active October 18, 2016 18:13
Show Gist options
  • Save theMikeD/9d655e5a2c722504818681b55f95b940 to your computer and use it in GitHub Desktop.
Save theMikeD/9d655e5a2c722504818681b55f95b940 to your computer and use it in GitHub Desktop.
Assigns slider counters to RS instances
jQuery(document).ready(function($) {
/**
* Inserts and updates RoyalSlider slide indicators.
* @src http://help.dimsemenov.com/kb/royalslider-javascript-api/creating-slider-index-indicator-slide-1-of-10
*/
var cnmd_create_rs_slide_counter = function() {
$(".royalSlider").each(function () {
var slider = this;
var sliderData = $(slider).data('royalSlider');
if ( sliderData ) {
var slideCountEl = $('<div class="rsSlideCount"></div>').appendTo($(slider) );
var updCount = function() {
slideCountEl.html( (sliderData.currSlideId+1) + ' / ' + sliderData.numSlides );
};
sliderData.ev.on('rsAfterSlideChange', updCount);
updCount();
}
});
};
setTimeout( cnmd_create_rs_slide_counter(), 1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment