繁体   English   中英

滚动链接

[英]Scrollify Links

我正在尝试使链接滚动到该部分。 我不明白为什么这行不通,链接要么不起作用,要么根本不滚动就转到该部分。 我正在使用Scrollify插件。

标头中的Javascript。 我应该放在页脚中吗? 我在某个地方读到它应该在我认为很奇怪的标题中...

 $(function() {
            $.scrollify({
                section : ".section-class-name",
                sectionName : "first",
                easing: "easeOutExpo",
                scrollSpeed: 1100,
                offset : 0,
                scrollbars: true,
                standardScrollElements: "",
                setHeights: true,
                before:function() {},
                after:function() {},
                afterResize:function() {},
                afterRender:function() {}
            })
        });

        $(".first").click(function(e) {
          e.preventDefault();
          $.scrollify("move", $(this).attr("href"));
       });

HTML

     <div class="section-class-name" data-name-section="first" style="background-color: red;">
            <a href="#second" class="first">Second</a><br>
        </div>
        <div class="section-class-name" data-name-section="second" style="background-color: orange;"></div>
        <div class="section-class-name" data-name-section="last" style="background-color: yellow;"></div>

问题出在您的点击事件中。 $.scrollify("move", $(this).attr("href")); 语法不正确,应为: $.scrollify.move($(this).attr("href"));

看来您在javascript中“ sectionName”的值是“ first”,但也许他们正在寻找HTML5数据属性的名称。 例如,在Scrollify插件网站的源代码中,他们使用data-section-name 在您的情况下,这将是name-section 另外,对于您的javascript中的“部分”选项,我认为他们要求的是HTML标签类型。 在您的情况下,该值应为div

在项目页面上,他们解释了http://projects.lukehaas.me/scrollify/#options中的选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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