Disable fullpage.js on mobile (touch) devices

你离开我真会死。 提交于 2019-12-03 14:30:25

Just don't initialize fullpage on touch devices. You will have to deal with the mobile/touch devices detection. Just search a bit on google or even here to find different alternatives.

It should look like this:

var isPhoneDevice = [ WHATEVER FUNCTION YOU WANT TO USE ]

//if it is not a phone device...
if(!isPhoneDevice){
    //initializing fullpage...
    $.fn.fullpage();
}

UPDATE

At the moment fullpage.js provides another alternative. Using the responsiveWidth and responsiveHeight options. This way fullpage.js will act as a normal website under the given values (in px).

This can also be combined with the class fp-auto-height-responsive in order to prevent fullPage.js to set the sections height on responsive and let you total control over them.

More in the docs.

I use this way!

var isPhoneDevice = "ontouchstart" in document.documentElement; 
$(document).ready(function() {
        if(isPhoneDevice){
            //mobile
        }
            else{
                //desktop               
                $.fn.fullpage();
            }
        });
user3654265

Even easier way that I came across here on Stackexchange - this is what I'm using:

if(screen.width < 480) { 
// do any 480 width stuff here, or simply do nothing
return;
} else {
// do all your cool stuff here for larger screens
}

Responsive design possibilities have been added to fullPage.js since last answer. You can seen example by the following link.

Read about responsiveWidth and responsiveHeight in documentation for details.

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