Skip to content

Instantly share code, notes, and snippets.

@theMikeD theMikeD/indicator.js
Last active Oct 18, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.