jQuery 單頁滾動插件:onepage-scroll

jopen 10年前發布 | 43K 次閱讀 其他jQuery插件 jQuery插件 onepage-scroll

onepage-scroll 是一款用于創建蘋果單頁滾動網站的 jQuery 插件。

$(".main").onepage_scroll({
   sectionContainer: "section",     // sectionContainer accepts any kind of selector in case you don't want to use section
   easing: "ease",                  // Easing options accepts the CSS3 easing animation such "ease", "linear", "ease-in", 
                                    // "ease-out", "ease-in-out", or even cubic bezier value such as "cubic-bezier(0.175, 0.885, 0.420, 1.310)"
   animationTime: 1000,             // AnimationTime let you define how long each section takes to animate
   pagination: true,                // You can either show or hide the pagination. Toggle true for show, false for hide.
   updateURL: false,                // Toggle this true if you want the URL to be updated automatically when the user scroll to each page.
   beforeMove: function(index) {},  // This option accepts a callback function. The function will be called before the page moves.
   afterMove: function(index) {},   // This option accepts a callback function. The function will be called after the page moves.
   loop: false,                     // You can have the page loop back to the top/bottom when the user navigates at up/down on the first/last page.
   keyboard: true,                  // You can activate the keyboard controls
   responsiveFallback: false,        // You can fallback to normal page scroll by defining the width of the browser in which
                                    // you want the responsive fallback to be triggered. For example, set this to 600 and whenever 
                                    // the browser's width is less than 600, the fallback will kick in.
   direction: "vertical"            // You can now define the direction of the One Page Scroll animation. Options available are "vertical" and "horizontal". The default value is "vertical".  
});

它具有以下功能、特點

  • (不)顯示右側圓點項目導航

    </li>

  • (不)顯示命名錨記

    </li>

  • 循環/禁止循環

    </li>

  • 回退(使用瀏覽器自帶滾動)/指定回退

    </li>

  • 支持鍵盤控制,左右上下/ Page Up / Page Donw / Home / End 等

    </li>

  • 水平/橫向滾動

    </li>

  • 回調函數

    </li> </ul>

     jQuery 單頁滾動插件:onepage-scroll

    鍵盤快捷鍵

    You can trigger page move with hotkeys as well:

    Up arrow / Page Up

    Pressing the up arrow or the page up key allows you to move the page up by one.

    Down arrow / Page Donw

    Pressing the down arrow or the page down key allows you to move the page down by one.

    Home

    Pressing the home key brings you back to the first page.

    End

    Pressing the end key brings you to the last page.

    Public Methods

    You can also trigger page move programmatically as well:

    $.fn.moveUp()

    This method allows you to move the page up by one. This action is equivalent to scrolling up/swiping down.

      $(".main").moveUp(); 

    $.fn.moveDown()

    This method allows you to move the page down by one. This action is equivalent to scrolling down/swiping up.

      $(".main").moveDown(); 

    $.fn.moveTo(page_index)

    This method allows you to move to the specified page index programatically.

      $(".main").moveTo(3); 

    Callbacks

    You can use callbacks to perform actions before or after the page move.

    beforeMove(current_page_index)

    This callback gets called before the plugin performs its move.

      $(".main").onepage_scroll({     beforeMove: function(index) {       ...     }   }); 

    afterMove(next_page_index)

    This callback gets called after the move animation was performed.

      $(".main").onepage_scroll({     afterMove: function(index) {       ...     }   }); 


    https://github.com/peachananr/onepage-scroll

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!