[英]Smooth scrolling animation to sections of page in IE on Windows Phone
我有一個包含各個部分的頁面,以及指向這些部分的鏈接。 我已經實現了以下滾動動畫:
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
這在Chrome,Safari,Firefox和iOS 7和Android上都可以完美運行,但是在Windows Phone(帶有IE的8)上,滾動會出現混亂,並且該部分的頂部不完整。
有什么想法使它起作用嗎?
IE瀏覽器具有平滑滾動功能的錯誤,動畫只有在滾動之后才會觸發。
對於IE11的所有win8用戶,默認情況下都處於啟用狀態。
這是我用來修復固定標頭上的jerkeyness的內容。
if(navigator.userAgent.match(/Trident\/7\./)) {
$('body').on("mousewheel", function () {
event.preventDefault();
var wd = event.wheelDelta;
var csp = window.pageYOffset;
window.scrollTo(0, csp - wd);
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.