fullpage.js最后一屏滾動(dòng)方式
這兩天公司網(wǎng)頁改版用到fullpage.js這個(gè)滾屏插件,頁面內(nèi)容整屏的滾動(dòng),不成問題,各種設(shè)置在網(wǎng)上也都有文檔。
而我遇到的問題就是,頁面內(nèi)容不滿屏的時(shí)候,和上面的內(nèi)容放一塊就太擠,單獨(dú)放一屏就太空,好尷尬的說

底部的footer部分就是我要單獨(dú)處理的部分,從網(wǎng)上搜了各種資料,總結(jié)了一下,個(gè)人覺著最簡單的方法,寫一篇文章以便以后查閱。
<!--footer及倒數(shù)第二屏的HTML-->
<body data-spy="scroll">
<div id="dowebok" class="container-fluid">
<div class="section" id="nextS">
<div class="sect ">
<div class="sectcenter4"></div>
</div>
<div class="sect sectbg2">
<div class="container">
<div class="sectcenter5"></div>
</div>
</div>
</div>
<div class="section footerss"><footer class="footer" id="footer"></footer></div>
</div>
</body>
//初始化滾屏的一些內(nèi)容,最重要的是設(shè)置好錨點(diǎn),這里重點(diǎn)是最后一屏(footer)的錨點(diǎn)footerl
$('#dowebok').fullpage({
verticalCentered: false,
resize: true,
navigation: true,
anchors: ['section-1', 'section-2', 'lastScreen','footerl'],
});
寫完這些,實(shí)現(xiàn)的就是下面如圖的效果,整個(gè)footer占了一屏,并且是垂直居中顯示的。

根據(jù)要實(shí)現(xiàn)的效果,要做的就是讓footer緊挨著#nextS這一屏(不垂直居中)+到#nextS這一屏的時(shí)候,再往下的滾動(dòng)距離就不能是一屏了(必須是footer的高度)。
按著整個(gè)思路,先解決css的問題
.section.footerss .fp-tableCell{//修改最后一屏display屬性
display: block!important;
}
//實(shí)現(xiàn)footer緊挨著#nextS這一屏顯示,底部出現(xiàn)

下面修改fullpage.js的問題,在引用的fullpage.js文件中找到performMovement這個(gè)方法,按照如下方法,修改一下,就可以達(dá)到想要的效果(footer緊挨著上一屏,并且滾動(dòng)的高度是footer的height)
function performMovement(v){
// using CSS3 translate functionality
if (options.css3 && options.autoScrolling && !options.scrollBar) {
if (v.anchorLink == 'footerl'){ //當(dāng)滾屏到最后一屏?xí)r間
footer_a = $('#nextS').height();//倒數(shù)第二屏的高度
footer_h = $('#footer').height(); //footer的高度
var translate3d = 'translate3d(0px, -' + (v.dtop - footer_a + footer_h) + 'px, 0px)';
}else{
var translate3d = 'translate3d(0px, -' + v.dtop + 'px, 0px)';
}
transformContainer(translate3d, true);
setTimeout(function () {
afterSectionLoads(v);
}, options.scrollingSpeed);
}
// using jQuery animate
else{
var scrollSettings = getScrollSettings(v);
$(scrollSettings.element).animate(
scrollSettings.options
, options.scrollingSpeed, options.easing).promise().done(function () { //only one single callback in case of animating `html, body`
afterSectionLoads(v);
});
}
}
這樣修改了之后,就不用擔(dān)心最后一屏不滿屏的問題了。
相關(guān)文章
從零開始學(xué)習(xí)jQuery (七) jQuery動(dòng)畫實(shí)現(xiàn) 讓頁面動(dòng)起來
開發(fā)人員一直痛疼做動(dòng)畫. 但是有了jQuery你會(huì)瞬間成為別人(那些不知道jQuery的人)眼里的動(dòng)畫高手! 本文將介紹jQuery的動(dòng)畫相關(guān)函數(shù).原來做動(dòng)畫如此簡單!2011-02-02
uploadify多文件上傳參數(shù)設(shè)置技巧
uploadify插件配置實(shí)用比較簡單,很多開發(fā)者都喜歡使用。但是它有個(gè)缺點(diǎn)就是剛加載的時(shí)候稍微慢了一秒左右,本文通過一段代碼實(shí)例給大家介紹uploadify多文件上傳參數(shù)設(shè)置技巧,朋友們一起學(xué)習(xí)吧2015-11-11
jquery實(shí)現(xiàn)背景墻聚光燈效果示例分享
這篇文章主要介紹了jquery實(shí)現(xiàn)背景墻聚光燈效果示例,需要的朋友可以參考下2014-03-03
jQuery實(shí)現(xiàn)氣球彈出框式的側(cè)邊導(dǎo)航菜單效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)氣球彈出框式的側(cè)邊導(dǎo)航菜單效果,通過css樣式控制結(jié)合jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)切換元素樣式實(shí)現(xiàn)提示框效果,非常美觀實(shí)用,需要的朋友可以參考下2015-09-09
easyui datagrid 表格中操作欄 按鈕圖標(biāo)不顯示的解決方法
下面小編就為大家?guī)硪黄猠asyui datagrid 表格中操作欄 按鈕圖標(biāo)不顯示的解決方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07
jQuery實(shí)現(xiàn)點(diǎn)擊水紋波動(dòng)動(dòng)畫
今天要為大家紹一款由jquery實(shí)現(xiàn)的鼠標(biāo)單擊出現(xiàn)水波特效。用鼠標(biāo)點(diǎn)擊頁面,你可以看到頁面不斷出面水波紋效果。然后水波紋漸漸消失。效果非常不錯(cuò)2016-04-04

