简体   繁体   中英

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 enabled for IE11 SO the ajax calls are calling frequently, so how to disable that setting using javascript or jquery, any reply is help full.

Thanks in advance.

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM