JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://rawgit.com/alvarotrigo/fullPage.js/master/dist/fullpage.css">
<script src="http://rawgit.com/alvarotrigo/fullPage.js/master/dist/fullpage.js"></script>
<button>
Add section
</button>
<div id="fullpage">
<div class="section">
<h1>Section 1</h1>
</div>
<div class="section ">
<h1>Section 1</h1>
</div>
<div class="section ">
<h1>Section 3</h1>
</div>
<div class="section">
<h1>Section 4</h1>
</div>
</div>
CSS
button{
position:fixed;
top: 20px;
left: 20px;
z-index:2;
}
JavaScript
init();
function init() {
$('#fullpage').fullpage({
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
navigation:true
});
}
//adding a section dynamically
$('button').click(function() {
$('#fullpage').append('<div class="section">New section</div>');
//remembering the active section / slide
var activeSectionIndex = $('.fp-section.active').index();
var activeSlideIndex = $('.fp-section.active').find('.slide.active').index();
$.fn.fullpage.destroy('all');
//setting the active section as before
$('.section').eq(activeSectionIndex).addClass('active');
//were we in a slide? Adding the active state again
if (activeSlideIndex > -1) {
$('.section.active').find('.slide').eq(activeSlideIndex).addClass('active');
}
init();
});