Skip to content

Commit

Permalink
fix(docs): don't display back-to-top when it is not needed (#1285)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Déramond <[email protected]>
  • Loading branch information
louismaximepiton and julien-deramond authored Jun 2, 2022
1 parent b3db327 commit 5ccdf2c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions site/assets/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,24 @@
sidenav.scrollTop = viewportTop - (sidenavHeight / 2) + (sidenavActiveLinkHeight / 2)
}
}

// Boosted mod: Remove back-to-top component from all pages when its not needed
['load', 'resize'].forEach(event => {
window.addEventListener(event, () => {
const removeClass = 'd-none'
const html = document.querySelector('html')
const btt = document.querySelector('.back-to-top')

// 100(px) comes from:
// - 40px of back-to-top component
// - 40px of navbar-minimized
// - 20px of 'security'
if (html.offsetHeight < window.innerHeight + 100) {
btt.classList.add(removeClass)
} else {
btt.classList.remove(removeClass)
}
})
})
// End mod
})()

0 comments on commit 5ccdf2c

Please sign in to comment.