generalize scroll offset prevention
parent
00b9c2b929
commit
520fa4986e
30
js/reveal.js
30
js/reveal.js
|
@ -410,8 +410,8 @@
|
||||||
// Listen to messages posted to this window
|
// Listen to messages posted to this window
|
||||||
setupPostMessage();
|
setupPostMessage();
|
||||||
|
|
||||||
// Prevent iframes from scrolling the slides out of view
|
// Prevent the slides from being scrolled out of view
|
||||||
setupIframeScrollPrevention();
|
setupScrollPrevention();
|
||||||
|
|
||||||
// Resets all vertical slides so that only the first is visible
|
// Resets all vertical slides so that only the first is visible
|
||||||
resetVerticalSlides();
|
resetVerticalSlides();
|
||||||
|
@ -642,22 +642,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an unfortunate necessity. Iframes can trigger the
|
* This is an unfortunate necessity. Some actions – such as
|
||||||
* parent window to scroll, for example by focusing an input.
|
* 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
|
* This scrolling can not be prevented by hiding overflow in
|
||||||
* CSS so we have to resort to repeatedly checking if the
|
* CSS (we already do) so we have to resort to repeatedly
|
||||||
* browser has decided to offset our slides :(
|
* checking if the slides have been offset :(
|
||||||
*/
|
*/
|
||||||
function setupIframeScrollPrevention() {
|
function setupScrollPrevention() {
|
||||||
|
|
||||||
if( dom.slides.querySelector( 'iframe' ) ) {
|
setInterval( function() {
|
||||||
setInterval( function() {
|
if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) {
|
||||||
if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) {
|
dom.wrapper.scrollTop = 0;
|
||||||
dom.wrapper.scrollTop = 0;
|
dom.wrapper.scrollLeft = 0;
|
||||||
dom.wrapper.scrollLeft = 0;
|
}
|
||||||
}
|
}, 1000 );
|
||||||
}, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue