Fullpage.js-停止在最后一个区域上滚动鼠标

问题描述 投票:1回答:1

我有5个整版部分,并按整个部分进行滚动设置。一切正常。

但是我需要,如果访问者在第4部分并向下滚动,则该网页不会向下滚动到最后一部分。我只想通过单击第四部分中的按钮来访问最后一部分。此按钮已完成并且可以使用,但是我现在不知道如何禁用自动滚动到最后一部分。

感谢任何想法!

fullpage.js
1个回答
0
投票

您可以使用方法禁用最后一节中的滚动

fullpage_api.setAllowScrolling(false, 'down');

有关文档的更多信息:https://github.com/alvarotrigo/fullPage.js#setallowscrollingboolean-directions

因此,您可以在诸如afterLoad的回调中使用它:

afterLoad: function(origin, destination, direction){
    var numSections = document.querySelectorAll('.fp-section').length;

    // Is the afterload firing for the last section?
    if(destionation.index === numSections -1){
       fullpage_api.setAllowScrolling(false, 'down');
    }

    // for all other sections, we enable scrolling again in case it was off
    else{
       fullpage_api.setAllowScrolling(true, 'down');
    }
}

然后在按钮上可以使用moveTo方法:

//moving to section 4
fullpage_api.moveTo(4)

有关文档中方法的更多信息:https://github.com/alvarotrigo/fullPage.js#movetosection-slide

© www.soinside.com 2019 - 2024. All rights reserved.