Skip to content

Commit a4ea547

Browse files
committed
Fix nav not highlighting Contact when scrolled to bottom
1 parent dd0a91b commit a4ea547

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎public/js/all.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎public/js/all.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎resources/js/script.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@
6363
scrollTime: 1000,
6464
topOffset: 0,
6565
});
66+
67+
// Fix for last section not highlighting when scrolled to bottom
68+
$(window).on('scroll', function() {
69+
var scrollTop = $(window).scrollTop();
70+
var windowHeight = $(window).height();
71+
var documentHeight = $(document).height();
72+
73+
// If scrolled to bottom (within 50px), activate the last nav item
74+
if (scrollTop + windowHeight >= documentHeight - 50) {
75+
var lastIndex = $('[data-scroll-index]:last').attr('data-scroll-index');
76+
$('[data-scroll-nav]').removeClass('active');
77+
$('[data-scroll-nav="' + lastIndex + '"]').addClass('active');
78+
}
79+
});
6680
/* Scrollit Scrollspy End */
6781

6882
/* ============================================================ */

0 commit comments

Comments
 (0)