alvarotrigo / fullPage.js

fullPage plugin by Alvaro Trigo. Create full screen pages fast and simple
http://alvarotrigo.com/fullPage/
GNU General Public License v3.0
35.27k stars 7.3k forks source link

"onLeave" with jQuery animate function #4369

Closed jackyyangtw closed 2 years ago

jackyyangtw commented 2 years ago

I have to custom the scrolling end position of section, because I have a fixed header, when scrolling up the header will move up and hide, scroll down it will show. The fixed header effect works like this https://www.ieiworld.com/en/product/model.php?II=864

So "onLeave", I use jQuery animate function to scroll to my custom position when scroll down or up. It work just fine. But I have the sticky header(like the example link dark grey header) which will navigate to other section using jquery animate function to implement too. But when clicking the sticky header navigation link, the page is going crazy, automatically scrolling up and down. How can I fix that?

fullpage version: 2.9.7

My fullpage setup is like this:

$( document ).ready(function(){
    $('#fullpage').fullpage({
        fitToSection: true,
        scrollBar: true,
        navigationPosition: 'right',
        sectionSelector: '.fullpage-section',
        normalScrollElements: ".spec-sec, .material-sec",
        autoScrolling: false,
        verticalCentered: false,

        onLeave: (index,nextIndex,direction)=> {
            let extScroll = topSecHeight - window.innerHeight;
            if(direction === "down") {
                $("html, body").animate({
                    scrollTop: allFullPageSec[nextIndex -1].offsetTop + extScroll + 50
                },700)

            }

            if(direction === "up") {
                 $("html, body").animate({
                    scrollTop: allFullPageSec[nextIndex -1].offsetTop  + extScroll - pcIEIHeaderHeight + 50
                },700)

            }
        },

    });
})
alvarotrigo commented 2 years ago

fullpage version: 2.9.7

We don't provide support for version 2 anymore. fullPage.js is currently on version 4 :)