Fullpage.js - Vertical Scroll with Keyboard

眉间皱痕 提交于 2019-12-24 04:04:07

问题


I am hoping someone can help me with my issue below.

I am using Fullpage.js (https://github.com/alvarotrigo/fullPage.js/) plugin to create a site where pages move horizontally. The plugin is designed to create full page sites where it vertically scrolls through each section, by scrolling or pressing down the keys, just like a parallax site.

In my file, I am only using the one section with left and right arrows to contain my multiple pages for horizontal scrolling. Like the example on http://alvarotrigo.com/fullPage/examples/scrolling.html Since I don't have multiple sections, when I hit the up/down keys it doesn't scroll the content at all.

Any suggestions would be greatly appreciated. Thanks in advance!


回答1:


Just assign the fullpage functions moveSlideRight and moveSlideLeft to your keydown events and turn off the default keyboard scrolling of fullpage.js by using $.fn.fullpage.setKeyboardScrolling(false)

$(document).keydown(function (e) {
    var shiftPressed = e.shiftKey;

    switch (e.which) {
        //up
        case 38:
        case 33:
            $.fn.fullpage.moveSlideLeft();
            break;

        //down
        case 40:
        case 34:
            $.fn.fullpage.moveSlideRight();
            break;

    }
});

Demo online



来源:https://stackoverflow.com/questions/29813330/fullpage-js-vertical-scroll-with-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!