![](/img/trans.png)
[英]scrollOverflow / slimScroll not working properly in fullPage.js
[英]FullPage.js scrollOverflow not working properly with loaded content
我正在整頁網站上工作,並決定使用Fullpage.js插件,但是在通過AJAX請求加載內容方面存在一些問題。 我使用JSON內容填充頁面,由於某些原因,scrollOverflow選項無法正常工作。 更有意思的是,它在XAMPP環境中運行良好,但在實時托管環境(Bluehost)中則失敗。 我感覺網站資源沒有正確加載,但是我不確定這是否會/將導致問題。 沒有控制台錯誤,並且正在加載所有資源。
初始化:
$(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 | © 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
});
包括:
<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>
據我所知,我已經加載了所有必需的文件和腳本。 提前致謝。
根據您的最新評論。 在將新內容加載到DOM結構中之后,您需要調用$.fn.fullpage.reBuild()
。
這樣,fullpage.js將重新計算內容大小並在必要時創建滾動條。
從文檔 :
reBuild()更新DOM結構以適合新窗口大小或其內容。 理想與AJAX調用或站點DOM結構中的外部更改結合使用 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.