sass-site/source/assets/js/components/navigation.ts
Jonny Gerig Meyer 77c4c3892d
Add eslint
2023-01-09 15:15:35 -05:00

27 lines
643 B
TypeScript

// Documentation Nav Scroll
$(function () {
// Vars
const nav = $('.sl-c-list-navigation-wrapper');
const sticky = nav.offset();
// Added sticky class when window top is great than nav top
function stickyNav() {
if (
nav.length > 0 &&
sticky &&
($(window).scrollTop() ?? 0) >= sticky.top
) {
$('.sl-l-medium-holy-grail__body').addClass('sl-js-nav--is-sticky');
} else {
$('.sl-l-medium-holy-grail__body').removeClass('sl-js-nav--is-sticky');
}
}
// When scrolling the page, execute stickyNav
$(window).on('scroll', function () {
stickyNav();
});
return stickyNav();
});