3

我正在为 niceScroll 使用这个功能,但它在 Safari 中不起作用。但是,它在 Firefox、chrome 甚至 IE 中运行良好。我该如何解决这个问题?

jQuery(function($) {
    $(document).ready(function()
    {
      $(".tableClass").niceScroll();
    });
 });
4

2 回答 2

0

jQuery Nicescroll 3.6.0中存在一些问题。这就是为什么它在 safari 中不能正常工作的原因。现在他们解决了。下载最新版本。jQuery Nicescroll 3.6.7并使用它。我认为它会在所有浏览器中正常工作。

于 2016-02-12T10:26:01.980 回答
-1

抱歉,我知道这并不能直接回答您的问题,但可以帮助您实现您想要实现的目标。您想通过使用 niceScroll 插件来实现什么功能?

如果在锚标签上平滑滚动,您可以这样做:

$(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;
      }
    }
  });
});

http://css-tricks.com/snippets/jquery/smooth-scrolling/

否则,如果它用于在向下滚动页面时柔化滚动效果,您可以这样做:

$(document).ready(function() {
    var page = $('#content');  // set to the main content of the page   
    $(window).mousewheel(function(event, delta, deltaX, deltaY){
        if (delta < 0) page.scrollTop(page.scrollTop() + 65);
        else if (delta > 0) page.scrollTop(page.scrollTop() - 65);
        return false;
    })
});

jquery垂直鼠标滚轮平滑滚动

两种解决方案都是跨浏览器兼容的。

于 2015-02-03T16:17:11.133 回答