Skip to content Skip to sidebar Skip to footer

How To Disable Smooth Scrolling In IE 11 Programatically

I am making ajax call based on scroll event that calls are working perfectly in all browsers except IE11 and I found the reason why because by deafault 'Smooth Scrolling' is enable

Solution 1:

All browsers on OS X, iOS Safari 8+, and a lot more have the same behavior. You can't and definitely shouldn't change it.

What you can do is limit the rate at which your function is called. Throttle it.

Open the your browser's console and look at this example. You'll see that the "scroll" is called often but the "throttled scroll" only once every 200ms at most.

var handler = function () {
	console.log('scroll');
};
var throttledHandler = throttle(function () {
	console.log('throttled scroll');
}, 200);

window.addEventListener('scroll', handler);
window.addEventListener('scroll', throttledHandler);

function throttle (callback, limit) {
    // source: http://sampsonblog.com/749/simple-throttle-function
    var wait = false;                 // Initially, we're not waiting
    return function () {              // We return a throttled function
        if (!wait) {                  // If we're not waiting
            callback.call();          // Execute users function
            wait = true;              // Prevent future invocations
            setTimeout(function () {  // After a period of time
                wait = false;         // And allow future invocations
            }, limit);
        }
    }
}
<p>scroll me</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p><p>1</p><p>1</p><p>1</p><p>1</p><p>1</p><p>---</p>

Post a Comment for "How To Disable Smooth Scrolling In IE 11 Programatically"