Skip to content

Instantly share code, notes, and snippets.

@mrichar1
Created March 11, 2015 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichar1/530776a75da951fc71a0 to your computer and use it in GitHub Desktop.
Save mrichar1/530776a75da951fc71a0 to your computer and use it in GitHub Desktop.
reveal.js - hotkey to jump to/from a named slide
Reveal.initialize({
keyboard: {
// '0' key will jump between current slide and slide-X
48: function() {jumpSlide()},
}
});
function jumpSlide() {
// The id of the slide you wish to jump to/from
target = "slide-X";
slide = Reveal.getCurrentSlide();
// If we're on the target slide, jump to original slide, if there was one
if (slide.id == target) {
Reveal.slide(orig['h'], orig['v']);
}
else {
// 'Save' the current slide's index to jump back to later
orig = Reveal.getIndices();
// Jump to the target slide
jump = Reveal.getIndices(document.getElementById(target));
Reveal.slide(jump['h'], jump['v']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment