简体   繁体   中英

fullpage.js How do I control the scrolling speed when jumping from one section to another?

I'm using fullpage.js with a lot of sections and anchor links, and from what I see the scrolling speed is the same wether the anchored section is just the next one or say 3 or 5 sections after.

So for example if I want to go from the top to the last section of the page with an anchor link, all the sections in between will show and scroll at the speed of light before I reach the last one, which is kinda problematic.

How can I change this speed depending on the distance between two sections?

I've never used this, but according to their documentation , I believe it can be done using the onLeave event:

$('#fullpage').fullpage({
    onLeave: function(index, nextIndex, direction){
    var idx = Math.abs(index - nextIndex)*.1;
    $.fn.fullpage.setScrollingSpeed(idx*700);
    }
})

You can change the "intensity" by adjusting the .1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM