diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-04-07 09:07:19 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-04-07 09:07:19 +0200 |
commit | 520fa4986eba954cba5d3a0ffa6f3697edba5047 (patch) | |
tree | 48d71827d1443ded8c2c59f09258dae4547716e0 | |
parent | 00b9c2b929dd46303696326c9b4bcbf3362578ac (diff) | |
download | fosdem-2018-presentation-520fa4986eba954cba5d3a0ffa6f3697edba5047.tar fosdem-2018-presentation-520fa4986eba954cba5d3a0ffa6f3697edba5047.tar.gz |
generalize scroll offset prevention
-rw-r--r-- | js/reveal.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/js/reveal.js b/js/reveal.js index 575214e..0b1cad7 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -410,8 +410,8 @@ // Listen to messages posted to this window setupPostMessage(); - // Prevent iframes from scrolling the slides out of view - setupIframeScrollPrevention(); + // Prevent the slides from being scrolled out of view + setupScrollPrevention(); // Resets all vertical slides so that only the first is visible resetVerticalSlides(); @@ -642,22 +642,22 @@ } /** - * This is an unfortunate necessity. Iframes can trigger the - * parent window to scroll, for example by focusing an input. + * This is an unfortunate necessity. Some actions – such as + * an input field being focused in an iframe or using the + * keyboard to expand text selection beyond the bounds of + * a slide – can trigger our content to be pushed out of view. * This scrolling can not be prevented by hiding overflow in - * CSS so we have to resort to repeatedly checking if the - * browser has decided to offset our slides :( + * CSS (we already do) so we have to resort to repeatedly + * checking if the slides have been offset :( */ - function setupIframeScrollPrevention() { + function setupScrollPrevention() { - if( dom.slides.querySelector( 'iframe' ) ) { - setInterval( function() { - if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) { - dom.wrapper.scrollTop = 0; - dom.wrapper.scrollLeft = 0; - } - }, 500 ); - } + setInterval( function() { + if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) { + dom.wrapper.scrollTop = 0; + dom.wrapper.scrollLeft = 0; + } + }, 1000 ); } |