Merge pull request #2286 from asottile/hash_without_history_2211

Add new 'hash: true' option which uses replaceState for url
This commit is contained in:
Hakim El Hattab 2018-12-19 10:52:15 +01:00 committed by GitHub
commit 6ef565c9fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -260,9 +260,12 @@ Reveal.initialize({
// Display the page number of the current slide
slideNumber: false,
// Push each slide change to the browser history
// Push each slide change to the browser history. Implies `hash: true`
history: false,
// Change the hash when changing slides -- impacts browser history with `history: true`
hash: false,
// Enable keyboard shortcuts for navigation
keyboard: true,

View File

@ -76,9 +76,12 @@
// Determine which displays to show the slide number on
showSlideNumber: 'all',
// Push each slide change to the browser history
// Push each slide change to the browser history. Implies `hash: true`
history: false,
// Change the hash when changing slides -- impacts browser history with `history: true`
hash: false,
// Enable keyboard shortcuts for navigation
keyboard: true,
@ -4137,8 +4140,6 @@
*/
function writeURL( delay ) {
if( config.history ) {
// Make sure there's never more than one timeout running
clearTimeout( writeURLTimeout );
@ -4147,8 +4148,12 @@
writeURLTimeout = setTimeout( writeURL, delay );
}
else if( currentSlide ) {
if ( config.history ) {
window.location.hash = locationHash();
}
else if ( config.hash ) {
window.history.replaceState(null, null, '#' + locationHash());
}
}
}