简体   繁体   English

FullPage.js scrollOverflow无法正确处理加载的内容

[英]FullPage.js scrollOverflow not working properly with loaded content

I'm working on a full page site and decided to use the Fullpage.js plugin, but I am having some issues in terms of loading content via an AJAX request. 我正在整页网站上工作,并决定使用Fullpage.js插件,但是在通过AJAX请求加载内容方面存在一些问题。 I am populating the pages with JSON content and for some reason the scrollOverflow option is not working properly. 我使用JSON内容填充页面,由于某些原因,scrollOverflow选项无法正常工作。 What is more interesting is that it works perfectly fine in the XAMPP environment, but fails when it's in the live hosted environment (Bluehost). 更有意思的是,它在XAMPP环境中运行良好,但在实时托管环境(Bluehost)中则失败。 I have a feeling site resources aren't being loaded properly, but I'm not sure if that could/would cause the issue. 我感觉网站资源没有正确加载,但是我不确定这是否会/将导致问题。 There are no console errors, and all resources are being loaded. 没有控制台错误,并且正在加载所有资源。

Initialization: 初始化:

$(document).ready(function() {
$.ajax({
    type: 'POST',
    url: 'content.json',
    dataType: 'json',
    contentType: "text/json; charset=utf-8",
    success: function(e) {
        $('.slide').each(function(index){
            console.log(index);
            $(this).children('.fp-tableCell').html('<span class = "center"><div class="circle-logo"><div class="circle-fill"><i class="'+e.platform[index].i+'"></i></div></div><h1 class = "montserrat">'+e.platform[index].h+'</h1><p class = "hind">'+e.platform[index].p+'</p><span>');
        });
        for(var i = 0; i<e.about.length; i++){
            $('#section2').children('.fp-tableCell').append('<h2 class = "montserrat">'+e.about[i].h+'</h2><p class = "hind">'+e.about[i].p+'</p>');
        }
        $('#section2').children('.fp-tableCell').append('<hr>');
        $('#section2').children('.fp-tableCell').append('<p class = "hind">CRAFTED BY DAVE | &copy; NATHAN</p>');
    },
    error: function(e){
        console.log(e);
    }
});

$('#downhint').click(function(){
    console.log('click');
    $.fn.fullpage.moveSectionDown();
});

$('#fullpage').fullpage({
    sectionsColor: ['transparent', '#021b80', '#FFF'],
    anchors: ['landing', 'platform', 'about'],
    menu: '#menu',
    scrollOverflow: true,
    slidesNavigation: true,
    afterLoad: function(anchorLink, index){

        $('.fp-table .active').css('overflow-y','auto');

        if(index == 1){
            $('#menu li:nth-child(1) a').addClass('active-link');
            $('#menu li:not(:nth-child(1)) a').removeClass('active-link');
        }
        if(index == 2){
            $('#menu li:nth-child(2) a').addClass('active-link');
            $('#menu li:not(:nth-child(2)) a').removeClass('active-link');
        }
        if(index == 3){
            $('#menu li:nth-child(3) a').addClass('active-link');
            $('#menu li:not(:nth-child(3)) a').removeClass('active-link');
        }

    }
});
$(window).scroll  
});

Includes: 包括:

    <link rel="stylesheet" type="text/css" href="css/index.css" />

    <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Hind' rel='stylesheet' type='text/css'>
    <link href='css/bootstrap.min.css' rel='stylesheet' type='text/css'>
    <link href='fonts/genericons/genericons/genericons.css' rel='stylesheet' type='text/css'>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="js/jquery.slimscroll.min.js"></script>
    <script type="text/javascript" src="fullpage/jquery.fullPage.js"></script>

From what I can tell I have loaded all required files and scripts. 据我所知,我已经加载了所有必需的文件和脚本。 Thanks in advance. 提前致谢。

Based on your last comment. 根据您的最新评论。 You need to call $.fn.fullpage.reBuild() just after loading the new content into the DOM structure. 在将新内容加载到DOM结构中之后,您需要调用$.fn.fullpage.reBuild()

This way fullpage.js will recalculate the content size and create the scroll bar when its necessary. 这样,fullpage.js将重新计算内容大小并在必要时创建滚动条。

From the docs : 文档

reBuild() Updates the DOM structure to fit the new window size or its contents. reBuild()更新DOM结构以适合新窗口大小或其内容。 Ideal to use in combination with AJAX calls or external changes in the DOM structure of the site. 理想与AJAX调用或站点DOM结构中的外部更改结合使用

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

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