Created
April 28, 2013 17:28
-
-
Save benfoxall/5477620 to your computer and use it in GitHub Desktop.
Snippet to keep reveal.js windows in sync using storage events.
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
// only for top level windows | |
if(window.top === window){ | |
// store the new slide index | |
Reveal.addEventListener('slidechanged', function(e) { | |
var send = e.indexh + ',' + e.indexv; | |
localStorage.setItem('rslide',send); | |
}); | |
// restore | |
window.addEventListener("storage", function(e){ | |
if(e.key == 'rslide'){ | |
var vals = e.newValue.split(',').map(parseFloat); | |
Reveal.slide(vals[0],vals[1]); | |
} | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment