【问题标题】:Check if it is last section fullPage.js检查它是否是最后一节 fullPage.js
【发布时间】:2015-08-18 02:55:38
【问题描述】:

我在我的网站中使用fullpage 插件,这是我的标记

<div id="fullpage">
  <div class="section section1">Some section</div>
  <div class="section section2">Some section</div>
  <div class="section section3">Some section</div>
  <div class="section section4">Last section</div>
</div>

在我的网站中,我想要执行以下操作:用户将向下滚动每个部分,当用户到达最后一个部分时,我想将用户重定向到另一个页面,我如何检查用户是否在整页的最后一个部分。 js?

【问题讨论】:

标签: javascript fullpage.js


【解决方案1】:

您可以在整页中使用afterLoad function 来实现此目的。以下代码 sn-p 应该让您了解如何使用 afterLoad 检查用户是否在最后一部分,如果是,则进行重定向:

$('#fullpage').fullpage({
        ...

        afterLoad: function(anchorLink, index){
            // Section indexes in fullpage start at 1
            if(index === $('#fullpage .section').length){
                window.location.href = "http://stackoverflow.com";
            }
        }

        ...
    });

【讨论】:

    【解决方案2】:

    嗨,我终于想通了,我检查了整个页面有一些回调,所以我使用了onLeave 回调,这是我的代码(在 CoffeeScript 中)

    $('#fullpage').fullpage
            onLeave: (index, nextIndex, direction) ->
    
                if index is 3 && direction is'down'
                    #redirect the user to a new page.
    

    【讨论】:

      猜你喜欢
      • 2012-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-26
      • 1970-01-01
      • 1970-01-01
      • 2020-01-27
      相关资源
      最近更新 更多