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:
commit
6ef565c9fb
@ -260,9 +260,12 @@ Reveal.initialize({
|
|||||||
// Display the page number of the current slide
|
// Display the page number of the current slide
|
||||||
slideNumber: false,
|
slideNumber: false,
|
||||||
|
|
||||||
// Push each slide change to the browser history
|
// Push each slide change to the browser history. Implies `hash: true`
|
||||||
history: false,
|
history: false,
|
||||||
|
|
||||||
|
// Change the hash when changing slides -- impacts browser history with `history: true`
|
||||||
|
hash: false,
|
||||||
|
|
||||||
// Enable keyboard shortcuts for navigation
|
// Enable keyboard shortcuts for navigation
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
|
|
||||||
|
25
js/reveal.js
25
js/reveal.js
@ -76,9 +76,12 @@
|
|||||||
// Determine which displays to show the slide number on
|
// Determine which displays to show the slide number on
|
||||||
showSlideNumber: 'all',
|
showSlideNumber: 'all',
|
||||||
|
|
||||||
// Push each slide change to the browser history
|
// Push each slide change to the browser history. Implies `hash: true`
|
||||||
history: false,
|
history: false,
|
||||||
|
|
||||||
|
// Change the hash when changing slides -- impacts browser history with `history: true`
|
||||||
|
hash: false,
|
||||||
|
|
||||||
// Enable keyboard shortcuts for navigation
|
// Enable keyboard shortcuts for navigation
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
|
|
||||||
@ -4137,18 +4140,20 @@
|
|||||||
*/
|
*/
|
||||||
function writeURL( delay ) {
|
function writeURL( delay ) {
|
||||||
|
|
||||||
if( config.history ) {
|
// Make sure there's never more than one timeout running
|
||||||
|
clearTimeout( writeURLTimeout );
|
||||||
|
|
||||||
// Make sure there's never more than one timeout running
|
// If a delay is specified, timeout this call
|
||||||
clearTimeout( writeURLTimeout );
|
if( typeof delay === 'number' ) {
|
||||||
|
writeURLTimeout = setTimeout( writeURL, delay );
|
||||||
// If a delay is specified, timeout this call
|
}
|
||||||
if( typeof delay === 'number' ) {
|
else if( currentSlide ) {
|
||||||
writeURLTimeout = setTimeout( writeURL, delay );
|
if ( config.history ) {
|
||||||
}
|
|
||||||
else if( currentSlide ) {
|
|
||||||
window.location.hash = locationHash();
|
window.location.hash = locationHash();
|
||||||
}
|
}
|
||||||
|
else if ( config.hash ) {
|
||||||
|
window.history.replaceState(null, null, '#' + locationHash());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user