fix issue with internal links
This commit is contained in:
19
js/reveal.js
19
js/reveal.js
@ -33,7 +33,7 @@ export const VERSION = '4.1.3';
|
||||
* https://revealjs.com
|
||||
* MIT licensed
|
||||
*
|
||||
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
||||
* Copyright (C) 2011-2021 Hakim El Hattab, https://hakim.se
|
||||
*/
|
||||
export default function( revealElement, options ) {
|
||||
|
||||
@ -2384,19 +2384,20 @@ export default function( revealElement, options ) {
|
||||
*/
|
||||
function onSlidesClicked( event ) {
|
||||
|
||||
const anchor = Util.closest( event.target, 'a[href^="#"]' );
|
||||
|
||||
// If a hash link is clicked, we find the target slide
|
||||
// and navigate to it. We previously relied on 'hashchange'
|
||||
// for links like these but that prevented media with
|
||||
// audio tracks from playing in mobile browsers since it
|
||||
// wasn't considered a direct interaction with the document.
|
||||
if( event.target.nodeName === 'A' ) {
|
||||
const hash = event.target.getAttribute( 'href' );
|
||||
if( /^#/.test( hash ) ) {
|
||||
const indices = location.getIndicesFromHash( hash );
|
||||
if( indices ) {
|
||||
Reveal.slide( indices.h, indices.v, indices.f );
|
||||
event.preventDefault();
|
||||
}
|
||||
if( anchor ) {
|
||||
const hash = anchor.getAttribute( 'href' );
|
||||
const indices = location.getIndicesFromHash( hash );
|
||||
|
||||
if( indices ) {
|
||||
Reveal.slide( indices.h, indices.v, indices.f );
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user