繁体   English   中英

将动画平滑滚动到Windows Phone上IE中的页面部分

[英]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.

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