【问题标题】:Smooth scroll plugin not allowing me to scroll down page平滑滚动插件不允许我向下滚动页面
【发布时间】:2017-08-01 15:15:34
【问题描述】:

我在github插件中添加了平滑滚动效果。

github.com/simov/simplr-smoothscroll

我在标注中添加了效果:

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"></script>
<script src="http://simov.github.io/simplr-smoothscroll/lib/jquery.simplr.smoothscroll.js"></script>

然后我为效果添加了这段代码:

$(function () { $.srSmoothscroll() });

完成此操作后,我的页面不再向下滚动。它只会向上滚动。为什么这不能正常工作?

我添加这个的网站是该网站的这个页面:

http://realtorcatch.com/test_index

我希望它模仿:

http://www.templatemonster.com/demo/51054.html

在 githubs 网站上,它说用法是这样的:

$(function () {
 $.srSmoothscroll({
    // defaults
    step: 55,
    speed: 400,
    ease: 'swing',
    target: $('body'),
    container: $(window)
  })
})

但这对我的情况没有帮助。

有没有人知道为什么这不向下滚动?

【问题讨论】:

  • 仍在寻找解决方案...

标签: javascript jquery html css scroll


【解决方案1】:

Zurb's Foundation Framework标准设置 我遇到了同样的问题,从 $.srSmoothscroll() 将 CSS 文件中的 body { height:100% } 更改为 body { height: auto }。这解决了我在 chrome47 (win7/osX 10.9) 上的问题。或者更改目标选项参数以使用包装器 div:

$.srSmoothscroll({
    target: $('wrapper')
});

【讨论】:

    【解决方案2】:

    看起来您的插件正在赶上滚动条。不用插件,你可以使用这个 sn-p 轻松实现它:

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

    更多详情请访问Smooth Scrolling

    【讨论】:

    • 当我用鼠标滚轮向下滚动时,我希望它能够平滑滚动。如果您使用滚动条并转到我的页面底部然后向上滚动,我希望它执行类似的操作,但可以上下工作。
    • @Becky 但与此同时,我猜那个插件会干扰你的平滑滚动......
    • 我只是不明白怎么做,因为这就是插件的用途。有办法解决吗?
    • @Becky Lemme 再次为您检查。如果没有,请尝试使用我的解决方案,如果有效,那就是双赢。
    • 谢谢。你知道,我说我想模仿它的网站,我指的是当你向上或向下滚动时的慢滚动效果。不是使该页面回到顶部的箭头。
    【解决方案3】:

    如果您使用 WordPress,为什么不直接下载这样的插件: https://wordpress.org/plugins/wp-smoother/

    看看它是否有效,如果不是它是一个主题/jQuery冲突问题

    【讨论】:

      猜你喜欢
      • 2020-09-05
      • 1970-01-01
      • 2012-08-27
      • 2021-05-28
      • 1970-01-01
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      相关资源
      最近更新 更多