mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Website: Update documentation scroll event handler (#12547)
Changes: - Updated the event handler for the sticky right-side navigation and the "Back to the top" button on docs pages only to run if those elements exist, and disabled the event handler on the documentation landing page.
This commit is contained in:
parent
4c073278a8
commit
d050f7f1f7
1 changed files with 11 additions and 7 deletions
|
|
@ -77,7 +77,9 @@ parasails.registerPage('basic-documentation', {
|
|||
return pagesBySectionSlug;
|
||||
})();
|
||||
// Adding a scroll event listener for scrolling sidebars and showing the back to top button.
|
||||
window.addEventListener('scroll', this.handleScrollingInDocumentation);
|
||||
if(!this.isDocsLandingPage){
|
||||
window.addEventListener('scroll', this.handleScrollingInDocumentation);
|
||||
}
|
||||
},
|
||||
|
||||
mounted: async function() {
|
||||
|
|
@ -269,7 +271,7 @@ parasails.registerPage('basic-documentation', {
|
|||
let backToTopButton = document.querySelector('div[purpose="back-to-top-button"]');
|
||||
let scrollTop = window.pageYOffset;
|
||||
let windowHeight = window.innerHeight;
|
||||
|
||||
// If the right nav bar exists, add and remove a class based on the current scroll position.
|
||||
if (rightNavBar) {
|
||||
if (scrollTop > this.scrollDistance && scrollTop > windowHeight * 1.5) {
|
||||
rightNavBar.classList.add('header-hidden', 'scrolled');
|
||||
|
|
@ -279,12 +281,14 @@ parasails.registerPage('basic-documentation', {
|
|||
rightNavBar.classList.remove('header-hidden');
|
||||
}
|
||||
}
|
||||
if (backToTopButton && scrollTop > 2500) {
|
||||
backToTopButton.classList.add('show');
|
||||
} else if (scrollTop === 0) {
|
||||
backToTopButton.classList.remove('show');
|
||||
// If back to top button exists, add and remove a class based on the current scroll position.
|
||||
if (backToTopButton){
|
||||
if (scrollTop > 2500) {
|
||||
backToTopButton.classList.add('show');
|
||||
} else if (scrollTop === 0) {
|
||||
backToTopButton.classList.remove('show');
|
||||
}
|
||||
}
|
||||
|
||||
this.scrollDistance = scrollTop;
|
||||
},
|
||||
clickScrollToTop: function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue