简体   繁体   English

如何使用jScroll插件?

[英]How to use jScroll plugin?

I would like to use the jScroll plugin in order to load in another web page when scrolling to the bottom of the page. 我想使用jScroll插件来滚动到页面底部时加载另一个网页。 I have set it up according to the instruction, and can see that there is some code being generated by the plugin, however it is not working as expected. 我已经按照说明进行了设置,可以看到该插件正在生成一些代码,但是该插件无法正常工作。 Any help here would be really appreciated. 在这里的任何帮助将不胜感激。

LINK TO PAGE 链接到页面

HTML: HTML:

        <script src="../js/jquery.jscroll.min.js"></script>

        <div class="wrapper scroll">

        <!-- Start module A - Header -->
        <div class="a">

            <div class="module__container header__mobile">

                <div class="work__flex--item">
                    <div class="header__mobile--img full work_overlay">

                    </div>
                    <div class="overlay__text">
                        <h3 class="overlay__text--header" style="margin-bottom: 6px !important;">AMUR</h3>
                        <p class="h5 overlay__text--sub" style="margin-bottom: 15px !important; marg

    in-top: 0px; font-weight: normal;">Materials making a difference.</p>
                </div>
            </div>

        </div>

        <div class="module__container header__other">

            <div class="header__text--container">
                <h2 style="color: white; margin-top: 35px !important; margin-bottom: 5px !important;">AMUR</h2> <!-- Title -->
                <h5 style="color: white; font-weight: normal; margin-top: 0px !important;">Materials making a difference.</h5> <!-- Subtitle -->
            </div>

            <div class="header__image--overlap">
                <img class="img__full" src="../css/images/work-template/amur/amur_overlay.png" style="height: auto !important;"> <!-- Path to header image file -->
            </div>

        </div>

    </div>
    <!-- End module A - Header -->

<a href="gohrvst.com/work/bench.html">next page</a>

    </div>

jQuery: jQuery的:

<script>
$('.scroll').jscroll();

$('.infinite-scroll').jscroll({
    autoTrigger: true
});
</script>

You have a couple issues to address: 您有几个问题要解决:

1) You need to target only the content area of your page. 1)您只需要定位页面的内容区域。 The 'jscroll' wants to load new content into an area once you scroll past it/to it's end. 一旦滚动过去/结束,“ jscroll”希望将新内容加载到区域中。 At the moment your wrapper div takes up all of the page from the top to the bottom. 目前,您的包装器div占据了从上到下的所有页面。 Try adding a new div around your page content only (eg: <div class="content">....</div> ). 尝试仅在页面内容周围添加一个新的div(例如: <div class="content">....</div> )。

2) add a class to your links (eg: jscroll-next )that you want to use to load in the next page - you will use this in your initialisation of the jscroll plugin to explicitly target that link as the new page. 2)在要用于下一页加载的链接中添加一个类(例如:jscroll-next)-您将在初始化jscroll插件时使用该类,以明确地将该链接定位为新页面。

Delete your jquery and change as such: 删除您的jquery并进行如下更改:

$('.content').jscroll({
    nextSelector: 'a.jscroll-next:last'
});

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

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