realbadrabbits
realbadrabbits

Reputation: 103

Disable Fullpage JS on click

I am initializing Fullpage.js on a button click like so:

$('.fullpage-trigger').on('click', function(event) {
    $('#fullpage').fullpage({
        navigation: true,
        navigationPosition: 'left',
        scrollOverflow: true
    });
});

I am trying to build a button that when clicked disables Fullpage.js, essentially toggling it on and off. Is this possible?

Thank you in advance!

Upvotes: 1

Views: 744

Answers (1)

karthick
karthick

Reputation: 12176

You can try destroying and recreating it

$('.fullpage-trigger').on('click', function(event) {
    if($('#fullpage').hasClass('fp-destroyed')){            
        $('#fullpage').fullpage({
            navigation: true,
            navigationPosition: 'left',
            scrollOverflow: true
        });
     } else {
        $.fn.fullpage.destroy('all');
     }
});

Upvotes: 2

Related Questions