Last active
December 14, 2015 10:39
-
-
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!)
This file contains hidden or 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
<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