Difference between revisions of "Template:XJTU-China/header"

Line 95: Line 95:
 
<!--headerTransition-->
 
<!--headerTransition-->
 
<script>
 
<script>
     // window.addEventListener('scroll', () => {
+
     window.addEventListener('scroll', () => {
    //    var h = document.getElementById('topHeader');
+
    //    height = h.clientHeight;
+
    //    let header = document.querySelector('header');
+
    //    let logo = document.querySelector('.logo');
+
    //    header.classList.toggle('sticky', window.scrollY > height);
+
    //    logo.classList.toggle('sticky', window.scrollY > height);
+
    // })
+
    scrollBar.on("scroll", (position) => {
+
 
         var h = document.getElementById('topHeader');
 
         var h = document.getElementById('topHeader');
 
         height = h.clientHeight;
 
         height = h.clientHeight;
 
         let header = document.querySelector('header');
 
         let header = document.querySelector('header');
 
         let logo = document.querySelector('.logo');
 
         let logo = document.querySelector('.logo');
        let y=position.scroll.y;
+
         header.classList.toggle('sticky', window.scrollY > height);
         header.classList.toggle('sticky', y > height);
+
         logo.classList.toggle('sticky', window.scrollY > height);
         logo.classList.toggle('sticky', y > height);
+
 
     });
 
     });
 +
 
</script>
 
</script>
  
 
</html>
 
</html>

Revision as of 13:59, 12 July 2021