Adding or removing sections/slides to fullPage.js after initialization

前端 未结 4 1502
灰色年华
灰色年华 2020-12-06 03:16

I have a tree-structured database and in my website I am going down the tree as I show their content in \"sections\" and \"slides\" of fullPage.js plugin. The problem is, wh

4条回答
  •  -上瘾入骨i
    2020-12-06 03:47

    Thanks, Alvaro! I also want to include my approach in order to remove sections and slides.

    To remove the active section at the bottom and go to upper section:

    $('#fullpage').on('click', 'button#removeSection', function() {
        var section = $('.fp-section.active');
        $.fn.fullpage.moveSectionUp();
        setTimeout(function(){
            section.remove();
        }, 700);
    });
    

    To remove the last slide and go to the slide on the left:

    $('#fullpage').on('click', 'button#removeSlide', function() {
        var slide = $('.fp-section.active').find('.slide.active');
        $.fn.fullpage.moveSlideLeft();
        setTimeout(function(){
            slide.remove();
        }, 700);
    });
    

    700ms is the default animation time. We should wait for the animation time to pass, in order to not to see the section/slide as it is being removed (what we observe as blink).

提交回复
热议问题