Elementor將背景圖片設為固定,但IE、EDGE上下滑動時,圖會抖看的很不舒服
這段程式碼是由這裡找的:为什么在IE上滚动时固定的背景图像会移动?
雖然沒有很懂,但套用下面這段程式碼解決。
if(navigator.userAgent.match(/Trident\/7\./)) {
$('body').on("mousewheel", function () {
event.preventDefault();
var wheelDelta = event.wheelDelta;
var currentScrollPosition = window.pageYOffset;
window.scrollTo(0, currentScrollPosition - wheelDelta);
});
$('body').keydown(function (e) {
var currentScrollPosition = window.pageYOffset;
switch (e.which) {
case 38: // up
e.preventDefault(); // prevent the default action (scroll / move caret)
window.scrollTo(0, currentScrollPosition - 120);
break;
case 40: // down
e.preventDefault(); // prevent the default action (scroll / move caret)
window.scrollTo(0, currentScrollPosition + 120);
break;
default: return; // exit this handler for other keys
}
});
}