jQuery-全屏滾動外掛程式【fullPage.js】API 使用方法總結

來源:互聯網
上載者:User

標籤:

jQuery-全屏滾動外掛程式fullPage.js使用方法總結

  作者github及:https://github.com/alvarotrigo/fullPage.js 

 今天說下jQuery的一款外掛程式fullpage.js,可以實現全屏滾動,非常流行的效果,相容性IE8+ 還算不錯,使用網站有小米,等電子產品、汽車全屏滾動展示,看起來比較高大上,接下來我全面解析下此款外掛程式!附我做的一個簡易效果,剛入部落格園,不知能怎麼上demo,只能了!

相容性:

  1. 支援 IE8+ 及其他現代瀏覽器。

主要功能:

1.支援滑鼠滾動;

2.支援前進後退鍵盤控制;

3.多個回呼函數;

4.支援手機.行動裝置;

5.支援視窗縮放自動調整;

6.可設定滾動寬度、背景顏色、捲動速度、迴圈選項、回調、文本對齊等等;

7.支援CSS3動畫;

 

實現方法:

1.插入jquery.fullPage.css;

2.插入jquery.js;

3.插入jquery-ui.js;(用於製作動畫)

4.插入jquery.fullpage.js;

1     <link rel="stylesheet" href="jquery.fullPage.css">2     <script src="jquery-1.11.3.min.js"></script>3     <script src="jquery-ui.js"></script>4     <script src="jquery.fullPage.js"></script>

HTML:

如果你想定義一個不同的出發點,而不是一段或一部分的第一個投影片,只需添加active section,並放在你想載入投影片位置前。

為了在一個投影片內進行擴充另外的橫向投影片,每個投影片將定義一個div。

 1 <body> 2     <div id="fullpage"> 3         <div class="section s1"> 4             <img src="img/bc8.jpg" alt=""> 5         </div> 6         <div class="section s2"> 7             <img src="img/bc8.jpg" alt=""> 8         </div> 9         <div class="section s3">10             <img src="img/bc8.jpg" alt="">11         </div>12         <div class="section s4">13             <img src="img/bc8.jpg" alt="">14         </div>15         <div class="section s5">16             <img src="img/bc8.jpg" alt="">17         </div>18     </div>19 </body>
javaScript:
1     <script>2         $(function(){3             $(‘#fullpage‘).fullpage({4                 navigation:‘true‘5             });6         });7     </script>

配置表:

1.選項

選項 類型 預設值 說明
verticalCentered 字串 true 內容是否垂直置中
resize 布爾值 false 字型是否隨著視窗縮放而縮放
slidesColor 函數 設定背景顏色
anchors 數組 定義錨連結
scrollingSpeed 整數 700 捲動速度,單位為毫秒
easing 字串 easeInQuart 滾動動畫方式
menu 布爾值 false 綁定菜單,設定的相關屬性與 anchors 的值對應後,菜單可以控制滾動
navigation 布爾值 false 是否顯示項目導航
navigationPosition 字串 right 項目導航的位置,可選 left 或 right
navigationColor 字串 #000 項目導航的顏色
navigationTooltips 數組 項目導航的 tip
slidesNavigation 布爾值 false 是否顯示左右滑塊的項目導航
slidesNavPosition 字串 bottom 左右滑塊的項目導航的位置,可選 top 或 bottom
controlArrowColor 字串 #fff 左右滑塊的箭頭的背景顏色
loopBottom 布爾值 false 滾動到最底部後是否滾回頂部
loopTop 布爾值 false 滾動到最頂部後是否滾底部
loopHorizontal 布爾值 true 左右滑塊是否迴圈滑動
autoScrolling 布爾值 true 是否使用外掛程式的滾動方式,如果選擇 false,則會出現瀏覽器內建的捲軸
scrollOverflow 布爾值 false 內容超過滿屏後是否顯示捲軸
css3 布爾值 false 是否使用 CSS3 transforms 滾動
paddingTop 字串 0 與頂部的距離
paddingBottom 字串 0 與底部距離
fixedElements 字串  
normalScrollElements    
keyboardScrolling 布爾值 true 是否使用鍵盤方向鍵導航
touchSensitivity 整數 5  
continuousVertical 布爾值 false 是否迴圈滾動,與 loopTop 及 loopBottom 不相容
animateAnchor 布爾值 true  
normalScrollElementTouchThreshold 整數 5

 

2.方法:

  • moveSectionUp() 向上滾動
  • moveSectionDown() 向下滾動
  • moveTo(section, slide) 滾動到
  • moveSlideRight() slide 向右滾動
  • moveSlideLeft() slide 向左滾動
  • setAutoScrolling() 設定頁面滾動方式,設定為 true 時自動滾動
  • setAllowScrolling() 添加或刪除滑鼠滾輪/觸控板控制
  • setKeyboardScrolling()添加或刪除鍵盤方向鍵控制
  • setScrollingSpeed() 定義以毫秒為單位的捲動速度

 

3、回呼函數

 

名稱 說明
afterLoad 滾動到某一屏後的回呼函數,接收 anchorLink 和 index 兩個參數,anchorLink 是錨連結的名稱,index 是序號,從1開始計算
onLeave 滾動前的回呼函數,接收 index、nextIndex 和 direction 3個參數:index 是離開的“頁面”的序號,從1開始計算;

 

nextIndex 是滾動到的“頁面”的序號,從1開始計算;

direction 判斷往上滾動還是往下滾動,值是 up 或 down。

afterRender 頁面結構產生後的回呼函數,或者說頁面初始化完成後的回呼函數
afterSlideLoad 滾動到某一水平滑塊後的回呼函數,與 afterLoad 類似,接收 anchorLink、index、slideIndex、direction 4個參數
onSlideLeave 某一水平滑塊滾動前的回呼函數,與 onLeave 類似,接收 anchorLink、index、slideIndex、direction 4個參數

jQuery-全屏滾動外掛程式【fullPage.js】API 使用方法總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.