From b645828707cd9752055f2e2c237f977207c4ea73 Mon Sep 17 00:00:00 2001
From: Hakim El Hattab <hakim.elhattab@gmail.com>
Date: Wed, 19 Dec 2018 11:04:29 +0100
Subject: [PATCH] ensure history api is available, default to hash: true with
 no history in demo #2286

---
 README.md    | 11 ++++++-----
 demo.html    |  2 +-
 js/reveal.js | 11 ++++++-----
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 00fe8d82..bd3965fd 100644
--- a/README.md
+++ b/README.md
@@ -260,12 +260,13 @@ Reveal.initialize({
 	// Display the page number of the current slide
 	slideNumber: false,
 
-	// 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`
+	// Add the current slide number to the URL hash so that reloading the
+	// page/copying the URL will return you to the same slide
 	hash: false,
 
+	// Push each slide change to the browser history. Implies `hash: true`
+	history: false,
+
 	// Enable keyboard shortcuts for navigation
 	keyboard: true,
 
@@ -283,7 +284,7 @@ Reveal.initialize({
 
 	// Change the presentation direction to be RTL
 	rtl: false,
-	
+
 	// When this is enabled, stepping left/right from a vertical stack
 	// to an adjacent vertical stack will land you at the same vertical
 	// index instead of the top.
diff --git a/demo.html b/demo.html
index 69f964bb..9471f8b8 100644
--- a/demo.html
+++ b/demo.html
@@ -393,8 +393,8 @@ Reveal.addEventListener( 'customevent', function() {
 			Reveal.initialize({
 				controls: true,
 				progress: true,
-				history: true,
 				center: true,
+				hash: true,
 
 				transition: 'slide', // none/fade/slide/convex/concave/zoom
 
diff --git a/js/reveal.js b/js/reveal.js
index afbc35a2..f3f4ae11 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -76,12 +76,13 @@
 			// Determine which displays to show the slide number on
 			showSlideNumber: 'all',
 
+			// Add the current slide number to the URL hash so that reloading the
+			// page/copying the URL will return you to the same slide
+			hash: false,
+
 			// 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,
 
@@ -4148,10 +4149,10 @@
 			writeURLTimeout = setTimeout( writeURL, delay );
 		}
 		else if( currentSlide ) {
-			if ( config.history ) {
+			if( config.history || !window.history ) {
 				window.location.hash = locationHash();
 			}
-			else if ( config.hash ) {
+			else if( config.hash ) {
 				window.history.replaceState(null, null, '#' + locationHash());
 			}
 		}
-- 
GitLab