1import Commons from "./commons.js" 2 3class Header extends Commons { 4 5 constructor() { 6 super(); 7 this.init(); 8 } 9 10 init() { 11 new Vue({ 12 el: '#header', 13 data: { 14 isOpened: false, 15 scrollPosition: 0, 16 footerVisible: false, 17 }, 18 created() { 19 this.scrollPosition = window.scrollY 20 console.log(`Header Vue component has been created.`) 21 }, 22 mounted() { 23 window.addEventListener('scroll', this.handleScroll) 24 let submenuLinks = document.querySelectorAll(".submenu a") 25 submenuLinks.forEach(link => { 26 link.addEventListener("click", () => { 27 this.isOpened = false; 28 }) 29 }) 30 31 this.handleScroll() 32 }, 33 methods: { 34 handleScroll() { 35 this.scrollPosition = window.scrollY 36 37 let footer = document.querySelector('footer'); 38 let footerPosition = footer.getBoundingClientRect(); 39 40 this.footerVisible = !(footerPosition.top <= window.innerHeight && footerPosition.bottom >= 0) && this.hasStickyHeader 41 }, 42 subMenu(event) { 43 const el = event.currentTarget; 44 el.classList.toggle('active'); 45 } 46 }, 47 watch: { 48 footerVisible(newVal) { 49 let classList = document.getElementById("bottom-bar"); 50 51 if (classList) { 52 classList = classList.classList; 53 54 if(newVal) classList.add("active"); 55 else classList.remove("active"); 56 } 57 } 58 }, 59 computed: { 60 hasStickyHeader() { 61 return this.scrollPosition > 30 62 } 63 }, 64 }); 65 } 66} 67 68new Header() 69 70export {}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.