Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable fullPage scrolling on mobile only #3109

Closed
anonet1 opened this issue Feb 15, 2018 · 25 comments
Closed

Disable fullPage scrolling on mobile only #3109

anonet1 opened this issue Feb 15, 2018 · 25 comments
Labels

Comments

@anonet1
Copy link

anonet1 commented Feb 15, 2018

Hi there,

Trying to "turn-off" fullPage on mobile only and have normal scrolling but wondering if there is any option for that?
I was trying to remove source for fullPage when less then 776px with javascript, but then it doesn't seem to be working on desktop.

@alvarotrigo
Copy link
Owner

alvarotrigo commented Feb 15, 2018

Check the responsive options in the docs (responsiveHeight and responsiveWidth) as well as the fp-auto-height-responsive class in case you need it.

More about it turning off fullpage.js on mobile or tablet devices here.

@alvarotrigo
Copy link
Owner

alvarotrigo commented Feb 15, 2018

@anonet1
Copy link
Author

anonet1 commented Feb 16, 2018

Hmmm what if you want to turn off this slide scrolling and have normal scrolling on mobile?

@alvarotrigo

@alvarotrigo
Copy link
Owner

@Anetk that's what the responsive options are for, as I said.

@majidzeno
Copy link

@Anetk you can remove fullpage in mobile
if($(window).width() < 1024){ $('#fullpage').removeAttr('id'); }
NOTE:you have to write this code BEFORE starting fullpage.js

@katiachumakova
Copy link

@majidzeno didn't exactly work but tweaked it to start fullpage only on screen sizes above desired px width:

if($(window).width() > 1023){ 
$('#fullpage').fullpage(...)
}

@pixelmultiplo
Copy link

I feel adding a class to multiple elements to disable something is a pretty bad design choice.

@alvarotrigo
Copy link
Owner

@marekmaurizio you are lucky then! fullPage.js is an open source project and you can contribute with your code an ideas 😄

@kirkbross
Copy link

Demo with fp-auto-height-responsive

Is the "responsive slides' extension the one I need to use fp-auto-height-responsive? (full screen scrolling >= x, normal scrolling, auto height <= x).

@alvarotrigo
Copy link
Owner

@kirkbross nope.
The extension is called "Responsive Slides". And its behaviour is explained in the the fullpage.js documentation:

responsiveSlides: (default false) Extension of fullpage.js. When set to true slides will be turned into vertical sections when responsive mode is fired. (by using the responsiveWidth or responsiveHeight options detailed above). Requires fullpage.js >= 2.8.5.

@HawkeyePierce89
Copy link

We need a disable option

const isPhone = Modernizr.phone; // https://github.com/hgoebl/mobile-detect.js

const options = {
	disable: isPhone ? true : false,
}

@alvarotrigo
Copy link
Owner

@HawkeyePierce89 why don't just use the destroy('all') function?

Or if you want to keep sections full height and some of the advantages of using fullPage.js such as lazyload, media autoplay/pause, bullet navigations or horizontal slides, why not using setResponsive(true)?

@alvarotrigo
Copy link
Owner

alvarotrigo commented Jun 13, 2019

@HawkeyePierce89 or easier yet. If you dont want to use fullPage.js at all in an iphone, why don't just avoid initialising it when you detect an iPhone?

@pixelmultiplo
Copy link

@marekmaurizio you are lucky then! fullPage.js is an open source project and you can contribute with your code an ideas 😄

If I contribute will the same code be used in the commercial version?

@alvarotrigo
Copy link
Owner

@marekmaurizio yeah of course. If your suggestions seems the way to go for it, it will go into fullPage.js code which is both open sourced and sold under a license, so everybody can benefit from it.

@ismail432
Copy link

Try it ...confirm it will work

<script> if (screen && screen.width > 768) { document.write('<script type="text/javascript" src="http://your-file-path/fullpage.js"><\/script>'); } </script>

@Ezra-Siton-UIX
Copy link

Ezra-Siton-UIX commented Apr 26, 2020

Update answer.

responsiveWidth option

new fullpage('#fullpage', {
     responsiveWidth: 900
});

Disabled under 900px (act like a normal page).

Example:
https://alvarotrigo.com/fullPage/examples/responsive.html 59

@Marius-Schwarz
Copy link

great, thanks for solving this. now I was wondering if it would be possible to still scroll-snap align (proximity) the start of the sections. thanks in advance.

@alvarotrigo
Copy link
Owner

Sure, just use the option fitToSection:true.

@saysonjerald
Copy link

saysonjerald commented Nov 6, 2020

note: this solution will work only for non-CDN CSS fullpage.css/fullpage.min.css
disable fullPage scrolling and customize height
open fullpage.css or fullpage.min.css and go somewhere to line 223 where you can find this code below,

.fp-responsive .fp-auto-height-responsive .fp-slide,
.fp-responsive .fp-auto-height-responsive .fp-tableCell,
.fp-responsive .fp-auto-height-responsive.fp-section {
  height: auto !important;
}

and change the value to height: inherit;

then use this on your javascript

new fullpage('#fullpage', {
     responsiveWidth: 768
});

then in order to customize the height on your mobile view, you must add this .fp-auto-height-responsive on each of your slides that you want to be customizable via your media query.

then go to CSS and add your media query

@media only screen and (max-width: 768px) {
      height: 500px !important; // <- 500 for example
 } 

@alvarotrigo
Copy link
Owner

@saysonjerald you don't actually need to modify anything :)
Just set the height to the content of the section/slide. For example

<div class="section fp-auto-height-responsive">
    <div class="content-wrappper">
         fasdfa
    </div>
</div>
@media only screen and (max-width: 768px) {
   .content-wrapper{
      height: 500px;
   }
}

@saysonjerald
Copy link

saysonjerald commented Nov 7, 2020

Yes, I tried that approach, but it's so weird why that fullPage.js is putting inline CSS on every slide that I have, like this one.

<section class="section section-resultDriven fp-auto-height-responsive fp-section active fp-completely" data-fp-styles="null" style="height: 676px;">
//my codes  here
</section>

again, I didn't put style="height: 676px;" inside the section tag. It just automatically generated. I don't know why so I modify the fullPage.css file so I can override this inline CSS which has a higher specificity.

@alvarotrigo
Copy link
Owner

but it's so weird why that fullPage.js is putting inline CSS on every slide that I have,

You shouldn't be worried about that inline css as it won't have any effect at all if you use fp-auto-height or fp-auto-height-responsive.

Modifying the CSS or the JS will only make it more difficult for you to:

  • Update to future fullpage.js version
  • Make sure you won't break anything with fullPage.js
  • Make sure you won't break anything with fullPage.js extensions.

Usually, if you can avoid modifying a library, do it :)

@Anu-Ujin
Copy link

Anu-Ujin commented Jun 11, 2021

@alvarotrigo Hi! How to disable scroliing in react mobile version. I tried
<ReactFullpage anchors={anchors} navigationPosition={"left"} navigation parallax={true} scrollOverflow={true} responsiveHeight={600} render={() => children} />
responsiveHeight={600}. but it's not working. Help me.

@alvarotrigo
Copy link
Owner

alvarotrigo commented Jun 11, 2021

@Anu-Ujin that should turn fulpage.js auto scrolling off when the height of your mobile device is less than 600px width.
Try playing with the width instead, that'd be easier. responsiveWidth="800"

And make sure to also add this on the HTML header part.

<meta name="viewport" content="width=device-width,initial-scale=1">

You have a full article with demos here:
https://alvarotrigo.com/fullPage/help/How-to-disable-fullpage-js-in-mobile-devices/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests