aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2020-03-31 13:09:44 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2020-03-31 13:09:44 +0200
commite4faf548049a2a45eeba6a0c7651c2c057be5836 (patch)
tree7ef5d4e27a3aed75897f42b94a42633b6404531a /js
parentdbbd82579e8ecd3b3f583cb6963120aa7da7d0b2 (diff)
downloadfosdem-2021-minimalism-presentation-e4faf548049a2a45eeba6a0c7651c2c057be5836.tar
fosdem-2021-minimalism-presentation-e4faf548049a2a45eeba6a0c7651c2c057be5836.tar.gz
move history api feature detection to utils
Diffstat (limited to 'js')
-rw-r--r--js/controllers/location.js4
-rw-r--r--js/utils/device.js4
2 files changed, 6 insertions, 2 deletions
diff --git a/js/controllers/location.js b/js/controllers/location.js
index 3b66876..3a9afd5 100644
--- a/js/controllers/location.js
+++ b/js/controllers/location.js
@@ -1,3 +1,5 @@
+import { supportsHistoryAPI } from '../utils/device.js'
+
/**
* Reads and writes the URL based on reveal.js' current state.
*/
@@ -98,7 +100,7 @@ export default class Location {
else if( currentSlide ) {
// If we're configured to push to history OR the history
// API is not avaialble.
- if( config.history || !window.history ) {
+ if( config.history || supportsHistoryAPI === false ) {
window.location.hash = this.getHash();
}
// If we're configured to reflect the current slide in the
diff --git a/js/utils/device.js b/js/utils/device.js
index ec1034f..1e787fb 100644
--- a/js/utils/device.js
+++ b/js/utils/device.js
@@ -12,4 +12,6 @@ export const isAndroid = /android/gi.test( UA );
// up slides. Zoom produces crisper results but has a lot of
// xbrowser quirks so we only use it in whitelisted browsers.
export const supportsZoom = 'zoom' in testElement.style && !isMobile &&
- ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) ); \ No newline at end of file
+ ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );
+
+export const supportsHistoryAPI = typeof window.history.replaceState === 'function' && !/PhantomJS/.test( UA ); \ No newline at end of file