Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The is pretty straightforward. I'm trying to find a way to get the active section Index number. I want the number to change when you scroll to a different section.

What I want to achieve: Demo

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
186 views
Welcome To Ask or Share your Answers For Others

1 Answer

Make use of fullPage.js callbacks or state classes.

Notice you have the slideIndex on the callbacks:

afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex){
    //do whatever here
    $(body).append(slideIndex);
}, 

Because the afterSlideLoad callback won't get fired on section change, you'll need to also make use of the afterLoad callback and get the slide number by using the state classes added by fullPage.js:

afterLoad: function(anchorLink, index){
    var slideNumber = $('.fp-section.active').find('.fp-slide.active').index() + 1
 //do whatever here
    $(body).append(slideNumber);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...