Last active
October 18, 2016 18:13
-
-
Save theMikeD/9d655e5a2c722504818681b55f95b940 to your computer and use it in GitHub Desktop.
Assigns slider counters to RS instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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