Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

scripts.js 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. /*!
  2. * Start Bootstrap - Clean Blog v6.0.5 (https://startbootstrap.com/theme/clean-blog)
  3. * Copyright 2013-2021 Start Bootstrap
  4. * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-clean-blog/blob/master/LICENSE)
  5. */
  6. window.addEventListener('DOMContentLoaded', () => {
  7. let scrollPos = 0;
  8. const mainNav = document.getElementById('mainNav');
  9. const headerHeight = mainNav.clientHeight;
  10. window.addEventListener('scroll', function() {
  11. const currentTop = document.body.getBoundingClientRect().top * -1;
  12. if ( currentTop < scrollPos) {
  13. // Scrolling Up
  14. if (currentTop > 0 && mainNav.classList.contains('is-fixed')) {
  15. mainNav.classList.add('is-visible');
  16. } else {
  17. console.log(123);
  18. mainNav.classList.remove('is-visible', 'is-fixed');
  19. }
  20. } else {
  21. // Scrolling Down
  22. mainNav.classList.remove(['is-visible']);
  23. if (currentTop > headerHeight && !mainNav.classList.contains('is-fixed')) {
  24. mainNav.classList.add('is-fixed');
  25. }
  26. }
  27. scrollPos = currentTop;
  28. });
  29. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...