fullPage.js icon indicating copy to clipboard operation
fullPage.js copied to clipboard

set a general offset variable

Open sylvainaerni opened this issue 9 years ago • 14 comments

This offset variable is useful when fullPage.js is wrapped into a bigger website, with an existing header is shifting all the scroll positions.

sylvainaerni avatar Aug 19 '15 12:08 sylvainaerni

Thanks! Could you provide a demo online for its use?

alvarotrigo avatar Aug 19 '15 13:08 alvarotrigo

Hi Álvaro,

not yet unfortunately, we have a NDA with the client. But the site will be online beginning of September, I'll share the link then.

I send you an image explaining rawly the structure, and I give you the code dealing with the fullPage.js, hope it helps!

[image: Inline image 1]

var offsetHeight = $('#header').height();

$('#fullpage').fullpage({ anchors: ['welcome', 'timepieces', 'trailer', 'media'], ... topOffset: offsetHeight,

    afterResize: function(){
        offsetHeight = $('#header').height();
        $(this).fullpage.setTopOffset(offsetHeight);
    }
  });

And BTW thank you very much for your great plugin :)

Cheers, Sylvain

On Wed, Aug 19, 2015 at 3:08 PM, Álvaro [email protected] wrote:

Could you provide a demo online for its use?

— Reply to this email directly or view it on GitHub https://github.com/alvarotrigo/fullPage.js/pull/1454#issuecomment-132585046 .

Liip AG // Rue de la Banque 1 // CH-1700 Fribourg Tel +41 26 422 25 11 // GPG 214E94A4 // www.liip.ch

sylvainaerni avatar Aug 19 '15 13:08 sylvainaerni

This feature would be great!

I'm working on a project that uses the ScrollMagic plugin "http://scrollmagic.io/" which basically uses offsets to trigger its events.

I'm doing some extra work to combine this two libraries.

alexandretperez avatar Aug 23 '15 00:08 alexandretperez

@alexandretperez that has nothing to do with this topic. You should be using scrollBar:true in fullpage.js for it and load the library in the afterRender callback.

alvarotrigo avatar Aug 23 '15 14:08 alvarotrigo

@alvarotrigo I'm sorry, I wasn't clear enough.

I needed stop scrolling the sections at 60px from the top, but changing the css to do that also affects the bottom, overflowing in 60px because the wrapper has 100% of the viewport.

So I change the code adding the "offset" option with value 0 by default.

Then I change this: var windowsHeight = $window.height();

To this: var windowsHeight = $window.height() - options.offset;

and in the function "init()" I added: if (options.offset) { container.css("top", options.offset); container.height(container.height() - options.offset); }

This solved my needs.

Cheers, Alexandre.

alexandretperez avatar Aug 23 '15 16:08 alexandretperez

Please add this. Right now the library assumes it's on the top level element, and requires ugly workarounds to work.

edenworky avatar May 24 '16 12:05 edenworky

@edenworky maybe for the next release.

alvarotrigo avatar May 24 '16 12:05 alvarotrigo

I also need an offset to land sections below my header.

bdkaat avatar Jul 13 '16 07:07 bdkaat

I too am wishing for this feature.

MikeiLL avatar Nov 18 '16 02:11 MikeiLL

I have another open PR for this concept.

https://github.com/alvarotrigo/fullPage.js/pull/2420

passion4code avatar Nov 18 '16 20:11 passion4code

what's up with this? I've purchased this plugin but doesn't work with that very obvious reason we have a navbar on the top of the page, so every scroll gets bigger (100% window height + the navbar height 66px), so every section is 66px longer that the bottom of the screen. Very frustrating.

csimpi avatar Jan 08 '20 18:01 csimpi

@csimpi have you considered using the paddingTop option so the fixed menu will be over the section but not taking any extra space?

alvarotrigo avatar Jan 08 '20 20:01 alvarotrigo

@alvarotrigo in my case I use Angular 8 and I have a main-menu component which has a <nav> container in the template with position: fixed. Since this is an Angular component it has a host element, so the fixed header is wrapped in the host html element. This pushed the whole site down and broke the full page's logic, the paddingTop didn't work.

Now I've refactored my code and added position: top to the host element, the paddingTop works well. But still it would be cool a feature when you add an element and its size would be subtracted from the 100% height.

csimpi avatar Jan 09 '20 02:01 csimpi

Now I've refactored my code and added position: top to the host element, the paddingTop works well. But still it would be cool a feature when you add an element and its size would be subtracted from the 100% height.

Thanks for the feedback! ;)

alvarotrigo avatar Feb 07 '20 17:02 alvarotrigo