Skip to content

Commit 8953f37

Browse files
committed
preventing all scroll events was not such an impressive idea after all...
1 parent 88cb10d commit 8953f37

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

js/impress.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@
190190
return false;
191191
}
192192

193+
// Sometimes it's possible to trigger focus on first link with some keyboard action.
194+
// Browser in such a case tries to scroll the page to make this element visible
195+
// (even that body overflow is set to hidden) and it breaks our careful positioning.
196+
//
197+
// So, as a lousy (and lazy) workaround we will make the page scroll back to the top
198+
// whenever slide is selected
199+
//
200+
// If you are reading this and know any better way to handle it, I'll be glad to hear about it!
201+
window.scrollTo(0, 0);
202+
193203
var step = el.stepData;
194204

195205
if ( $(".step.active", impress) ) {
@@ -296,17 +306,6 @@
296306
select( getElementFromUrl() );
297307
}, false);
298308

299-
// Sometimes it's possible to trigger focus on first link with some keyboard action.
300-
// Browser in such a case tries to scroll the page to make this element visible
301-
// (even that body overflow is set to hidden) and it breaks our careful positioning.
302-
//
303-
// So, as a lousy (and lazy) workaround any scroll event will make the page scroll back to the top.
304-
//
305-
// If you are reading this and know any better way to handle it, I'll be glad to hear about it!
306-
window.addEventListener("scroll", function ( event ) {
307-
window.scrollTo(0, 0);
308-
}, false);
309-
310309
// START
311310
// by selecting step defined in url or first step of the presentation
312311
select(getElementFromUrl() || steps[0]);

0 commit comments

Comments
 (0)