don't write '#/' to url on first slide, remove history api feature detection
parent
7ebade7248
commit
c91074761a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,3 @@
|
||||||
import { supportsHistoryAPI } from '../utils/device.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and writes the URL based on reveal.js' current state.
|
* Reads and writes the URL based on reveal.js' current state.
|
||||||
*/
|
*/
|
||||||
|
@ -121,15 +119,24 @@ export default class Location {
|
||||||
this.writeURLTimeout = setTimeout( this.writeURL, delay );
|
this.writeURLTimeout = setTimeout( this.writeURL, delay );
|
||||||
}
|
}
|
||||||
else if( currentSlide ) {
|
else if( currentSlide ) {
|
||||||
|
|
||||||
|
let hash = this.getHash();
|
||||||
|
|
||||||
// If we're configured to push to history OR the history
|
// If we're configured to push to history OR the history
|
||||||
// API is not avaialble.
|
// API is not avaialble.
|
||||||
if( config.history || supportsHistoryAPI === false ) {
|
if( config.history ) {
|
||||||
window.location.hash = this.getHash();
|
window.location.hash = hash;
|
||||||
}
|
}
|
||||||
// If we're configured to reflect the current slide in the
|
// If we're configured to reflect the current slide in the
|
||||||
// URL without pushing to history.
|
// URL without pushing to history.
|
||||||
else if( config.hash ) {
|
else if( config.hash ) {
|
||||||
window.history.replaceState( null, null, '#' + this.getHash() );
|
// If the hash is empty, don't add it to the URL
|
||||||
|
if( hash === '/' ) {
|
||||||
|
window.history.replaceState( null, null, window.location.pathname + window.location.search );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.history.replaceState( null, null, '#' + hash );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// UPDATE: The below nuking of all hash changes breaks
|
// UPDATE: The below nuking of all hash changes breaks
|
||||||
// anchors on pages where reveal.js is running. Removed
|
// anchors on pages where reveal.js is running. Removed
|
||||||
|
@ -141,6 +148,7 @@ export default class Location {
|
||||||
// else {
|
// else {
|
||||||
// window.history.replaceState( null, null, window.location.pathname + window.location.search );
|
// window.history.replaceState( null, null, window.location.pathname + window.location.search );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,4 @@ export const isAndroid = /android/gi.test( UA );
|
||||||
// up slides. Zoom produces crisper results but has a lot of
|
// up slides. Zoom produces crisper results but has a lot of
|
||||||
// xbrowser quirks so we only use it in whitelisted browsers.
|
// xbrowser quirks so we only use it in whitelisted browsers.
|
||||||
export const supportsZoom = 'zoom' in testElement.style && !isMobile &&
|
export const supportsZoom = 'zoom' in testElement.style && !isMobile &&
|
||||||
( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );
|
( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );
|
||||||
|
|
||||||
export const supportsHistoryAPI = typeof window.history.replaceState === 'function' && !/PhantomJS/.test( UA );
|
|
Loading…
Reference in New Issue