If we make a simple test case like:
document.documentElement.addEventListener('scroll', function() {
console.log(document.documentElement.scrollTop);
});
And then go and scroll using the scrollbar by clicking the track, or by using PageDown/PageUp, then we can see that we only get one event at the end of the scrolling animation.
Now theoretically I could fix some of that behaviour by simulating the scroll events. Example code with jQuery and Underscore:
$(function () {
var $document = $(document), until = 0;
var throttleScroll = _.throttle(function () {
$document.scroll();
if (+new Date < until) {
setTimeout(throttleScroll, 50);
}
}, 50);
$document.keydown(function (evt) {
if (evt.which === 33 || evt.which === 34) {
until = +new Date + 300;
throttleScroll();
}
});
});
But it still does not work. We only get scroll events with the original scrollTop
and the destination scrollTop
, no values in between.
If then go and console.log(document.documentElement.scrollTop)
every 10ms, then we can see that IE just does not update the scrollTop
as it scrolls.
This is very frustrating if we want to "pin" something to the scroll position. It gets jerky with IE.
I did not observe this behaviour on any other browser, and did not test with previous IE versions.
If anyone has found a way to fix IE's behaviour (maybe there's a magic CSS to turn off smooth scrolling in IE 11?) then I would very much like to hear about it!
Thanks :-)