Skip to content

Instantly share code, notes, and snippets.

@lfac-pt
Last active December 14, 2015 10:39
Show Gist options
  • Save lfac-pt/5073918 to your computer and use it in GitHub Desktop.
Save lfac-pt/5073918 to your computer and use it in GitHub Desktop.
Snippet to add the page number to a reveal.js presentation. (Does not add a number to the first slide!)
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
function currentPageFormatter(event) {
var formattedStr;
if (event.indexh === 0) {
return "";
}
formattedStr = event.indexh;
if (event.indexv) {
formattedStr += "/" + event.indexv;
}
return formattedStr;
}
Reveal.addEventListener( 'ready', function( event ) {
$('<aside class="controls slide-number" style="display: block; left: 10px; right: initial;bottom: -30px; text-align: center;"></aside>')
.text(currentPageFormatter(event))
.appendTo('.reveal.center');
} );
// Fires each time a new slide is activated
Reveal.addEventListener( 'slidechanged', function( event ) {
// event.previousSlide, event.currentSlide, event.indexh, event.indexv
$(".slide-number").text(currentPageFormatter(event));
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment