1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-10-23 19:26:12 +02:00

prevent iframes from auto-focusing and disabling keyboard nav, controllable via preventIframeAutoFocus

This commit is contained in:
Hakim El Hattab
2025-09-16 12:05:59 +02:00
parent 8bb6674303
commit c9d6785df2
6 changed files with 25 additions and 4 deletions

2
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -168,6 +168,9 @@ export default {
// - false: All iframes with data-src will be loaded only when visible
preloadIframes: null,
// Prevent embedded iframes from automatically focusing on themselves
preventIframeAutoFocus: true,
// Can be used to globally disable auto-animation
autoAnimate: true,

View File

@@ -468,6 +468,24 @@ export default class SlideContent {
let iframe = event.target;
if( this.Reveal.getConfig().preventIframeAutoFocus ) {
let elapsed = 0;
const interval = 100;
const maxTime = 1000;
const checkFocus = () => {
if( document.activeElement === iframe ) {
document.activeElement.blur();
} else if( elapsed < maxTime ) {
elapsed += interval;
setTimeout( checkFocus, interval );
}
};
setTimeout( checkFocus, interval );
}
if( iframe && iframe.contentWindow ) {
let isAttachedToDOM = !!closest( event.target, 'html' ),