IE Fix for "jumpy" fixed bacground
---------- THE UPDATED VERSION OF THIS PROTIP IS AVAILABLE HERE -----------
If you are using fixed backgrounds on your website such as here, you may experience issues on IE (I'm on IE11 Windows 8).
Your fixed backgrounds may jump around and jitter when scrolling with mousewheel. (Like this)
A way to fix this is to disable smooth scrolling on IE, but it won't help your users.
So another way is to fix it by overriding the mousewheel event on IE like this.
if(navigator.userAgent.match(/Trident\/7\./)) { // if IE
$('body').on("mousewheel", function () {
// remove default behavior
event.preventDefault();
//scroll without smoothing
var wheelDelta = event.wheelDelta;
var currentScrollPosition = window.pageYOffset;
window.scrollTo(0, currentScrollPosition - wheelDelta);
});
}
Hope this can help someone :)
PS :
Also -webkit-backface-visibility: hidden;
can break your background-attachement
in chrome (speak from experience).
---------- THE UPDATED VERSION OF THIS PROTIP IS AVAILABLE HERE -----------
Written by Benoit Rospars
Related protips
9 Responses
Your solution was TIP-TOP my friend! Thank you greatly!!
This is great, but the issue is still there for touchscreen Win8,1 laptops when you swipe to scroll or use the trackpad to scroll and also for keyboard up and down. Let's hope Microsoft fix it soon, it was first reported in February 2014!
Worked perfectly, thank you!
Oddly, this worked on a thursday, then when I came in the next day it did not fix the issue and broke all other browsers. In all but IE the CSS was 'broken' in such a way that the background was gone and all elements floated left while IE looked fine but the jumping was an issue again. Has anyone else noticed the return of this issue?
My matter was able to be settled. It is thanks to you. Thank you very much. from Japan.
Great fix my friend,
this solution doeasn't work for me. can you help me? ;)
Hello, this code works with mousewheel event, but if I try to scroll website using the scroll-bar obviously this code don't work.
Any solution?
Thanks.
This solution was great and saved my time. Thanks friend!