fix issue with internal links

This commit is contained in:
hakimel
2021-11-11 08:16:28 +01:00
parent ad46e6293c
commit 4e8a1b3802
7 changed files with 20 additions and 18 deletions

View File

@ -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();
}
}