question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use Barba.js and Fullpage.js

See original GitHub issue

Hi,

Let me start by saying that i am a noob at this.

I really can’t use Barba and Fullpage.js, i have tried a lot of different approaches but at the moment i am almost giving up.

I have been trying to use Fullpage.js with external pages and it is all fine with this. The main issue is when paired with Barba.js to make the transition from page to page the styles sometimes aren’t loaded and the menu from the first page is passed into the other.

I have tried using the destroy function of Fullpage.js, barba.js views and the Dispatcher to no avail.

I am stuck and would really like some help getting this thing going.

I am using Wordpress btw.

First file where I put all my functions:

` var $ = jQuery.noConflict();

function cordeiro() {

if($(‘#mimadre’).length){

$(‘#mimadre’).fullpage({

    menu: '#menu',
    anchors: ['about', 'services', 'work', 'team', 'contacts'],
    navigation: true,
    autoScrolling: true,
    navigationPosition: 'right',
    css3: true,
    scrollOverflow: true,
    controlArrows: false,
    resize: true,
    scrollOverflowOptions: {

        fadeScrollbars: true

    },
  })

$(‘#mimadre’).fullpage.reBuild();

} };

function cabrone() {

if($('#cabrone').length){


    $('#cabrone').fullpage({

    menu: '#menutop',
    navigation: false,
    autoScrolling: true,
    navigationPosition: 'right',
    css3: true,
    scrollOverflow: true,
    controlArrows: false,
    resize: true,

    scrollOverflowOptions: {

        fadeScrollbars: true

    },

    })

};

$('#cabrone').fullpage.reBuild();
}

`

Second file for barba where i call functions that are in the global scope. I had a more complete solutions with the views and data-namespace but i actually didn’t saved it.

` Barba.Dispatcher.on(‘newPageReady’, function(current, prev, newContainer) {

        cordeiro();

        cabrone();

            menu();

        lettering();

});

Barba.Pjax.start();`

Any help in the right direction would be appreciated and you can call me names if needed. 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
gustavo-acommented, Mar 23, 2018

You have to call $.fn.fullpage.destroy('all'); every time you load a new page with fullpage. And then create a new instance of it.

Just like that:

if ( $( 'html' ).hasClass( 'fp-enabled' ) ) {
   $.fn.fullpage.destroy('all');
}

$('#mimadre').fullpage({

    menu: '#menu',
    anchors: ['about', 'services', 'work', 'team', 'contacts'],
    navigation: true,
    autoScrolling: true,
    navigationPosition: 'right',
    css3: true,
    scrollOverflow: true,
    controlArrows: false,
    resize: true,
    scrollOverflowOptions: {

        fadeScrollbars: true

    },
  })

That was the only way I got it working

3reactions
Tedowskicommented, Mar 24, 2018

Did you try adding the code Gustavo wrote inside of the Dispatcher together with the init of the fullpage.js?

So it goes like this

Barba.Dispatcher.on('newPageReady', function(current, prev, newContainer) {
if ( $( 'html' ).hasClass( 'fp-enabled' ) ) {
   $.fn.fullpage.destroy('all');
}

$('#mimadre').fullpage({

    menu: '#menu',
    anchors: ['about', 'services', 'work', 'team', 'contacts'],
    navigation: true,
    autoScrolling: true,
    navigationPosition: 'right',
    css3: true,
    scrollOverflow: true,
    controlArrows: false,
    resize: true,
    scrollOverflowOptions: {

        fadeScrollbars: true

    },
  })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to use fullpage.js with barba.js - Stack Overflow
I making a site that have a 6 section in the homepage with links to some work. I trying to use barba view...
Read more >
Flip Plugin doesnt work properly after page transition with ...
I faced a problem using gsap Flip plugin, in the leavebarba hoook works fine, also when i leave the home page, but after...
Read more >
Barba.js - 08. GSAP Page Transition Tutorials - Introduction
Learn how to build custom page transitions using Barba. js and GreenSock.Working Files:https://github.com/Ihatetomatoes/barbajs-101Live ...
Read more >
Barba.js with GSAP - 10. Export, Import Animations - YouTube
Learn how to export and import animations from individual files.Working Files:https://github.com/Ihatetomatoes/barbajs-101Live ...
Read more >
Transitions - barba.js
Barba allows you to define a global transition, that run everywhere on your site, and/or specific transitions using rules that run when navigating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found