Skip to content

Commit 5f8ab7b

Browse files
committed
- Improved bottom section detection when using fp-auto-heigh for it.
1 parent 7df75bd commit 5f8ab7b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

jquery.fullPage.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -895,16 +895,24 @@
895895
var scrollDirection = getScrollDirection(currentScroll);
896896
var visibleSectionIndex = 0;
897897
var screen_mid = currentScroll + ($window.height() / 2.0);
898+
var isAtBottom = $body.height() - $window.height() === currentScroll;
899+
var sections = document.querySelectorAll(SECTION_SEL);
900+
901+
//when using `auto-height` for a small last section it won't take most of the viewport
902+
if(isAtBottom){
903+
visibleSectionIndex = sections.length - 1;
904+
}
898905

899906
//taking the section which is showing more content in the viewport
900-
var sections = document.querySelectorAll(SECTION_SEL);
901-
for (var i = 0; i < sections.length; ++i) {
902-
var section = sections[i];
907+
else{
908+
for (var i = 0; i < sections.length; ++i) {
909+
var section = sections[i];
903910

904-
// Pick the the last section which passes the middle line of the screen.
905-
if (section.offsetTop <= screen_mid)
906-
{
907-
visibleSectionIndex = i;
911+
// Pick the the last section which passes the middle line of the screen.
912+
if (section.offsetTop <= screen_mid)
913+
{
914+
visibleSectionIndex = i;
915+
}
908916
}
909917
}
910918

0 commit comments

Comments
 (0)