File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 895
895
var scrollDirection = getScrollDirection ( currentScroll ) ;
896
896
var visibleSectionIndex = 0 ;
897
897
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
+ }
898
905
899
906
//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 ] ;
903
910
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
+ }
908
916
}
909
917
}
910
918
You can’t perform that action at this time.
0 commit comments