|
34 | 34 | // window.addEventListener('resize', fitNavMenuInit) |
35 | 35 |
|
36 | 36 | if ((navControl = document.querySelector('main .nav-control'))) navControl.addEventListener('click', revealNav) |
37 | | - |
38 | | - // function scrollItemToMiddle (el, parentEl) { |
39 | | - // var adjustment = (el.getBoundingClientRect().height - parentEl.getBoundingClientRect().height) * 0.5 + el.offsetTop |
40 | | - // if (adjustment > 0) parentEl.scrollTop = adjustment |
41 | | - // } |
42 | | - |
43 | | - // function fitNavMenuInit (e) { |
44 | | - // window.removeEventListener('scroll', fitNavMenuOnScroll) |
45 | | - // navMenu.element.style.height = '' |
46 | | - // if ((navMenu.preferredHeight = navMenu.element.getBoundingClientRect().height) > 0) { |
47 | | - // // QUESTION should we check if x value > 0 instead? |
48 | | - // if (window.getComputedStyle(nav).visibility === 'visible') { |
49 | | - // if (!navMenu.encroachingElement) navMenu.encroachingElement = document.querySelector('footer.footer') |
50 | | - // fitNavMenu(navMenu.preferredHeight, (navMenu.viewHeight = window.innerHeight), navMenu.encroachingElement) |
51 | | - // window.addEventListener('scroll', fitNavMenuOnScroll) |
52 | | - // } |
53 | | - // if (currentPageItem && e.type !== 'resize') { |
54 | | - // scrollItemToMiddle(currentPageItem.querySelector('.nav-link'), navMenu.element) |
55 | | - // } |
56 | | - // } |
57 | | - // } |
58 | | - |
59 | | - // function fitNavMenuOnScroll () { |
60 | | - // fitNavMenu(navMenu.preferredHeight, navMenu.viewHeight, navMenu.encroachingElement) |
61 | | - // } |
62 | | - |
63 | | - // function fitNavMenu (preferredHeight, availableHeight, encroachingElement) { |
64 | | - // var reclaimedHeight = availableHeight - encroachingElement.getBoundingClientRect().top |
65 | | - // navMenu.element.style.height = reclaimedHeight > 0 ? Math.max(0, preferredHeight - reclaimedHeight) + 'px' : '' |
66 | | - // } |
67 | | - // var navMenuControl = document.querySelector('.main-nav-parent') |
68 | | - // // var navWrap = document.querySelector('.currentNav-wrap') |
69 | | - |
70 | | - // navMenuControl.addEventListener('click', function () { |
71 | | - // // navWrap.style.display = 'none' |
72 | | - // for (var i = 0; i < navItems.length; i++) { |
73 | | - // navItems[i].classList.remove('is-active') |
74 | | - // navItems[i].classList.remove('is-inactive') |
75 | | - // } |
76 | | - // this.style.display = 'none' |
77 | | - // }) |
78 | | - |
79 | 37 | var navMenuControl |
80 | 38 | if (document.querySelector('.main-nav-parent')) { |
81 | 39 | navMenuControl = document.querySelector('.main-nav-parent') |
|
84 | 42 | for (var i = 0; i < navItems.length; i++) { |
85 | 43 | navItems[i].classList.remove('is-active') |
86 | 44 | navItems[i].classList.remove('is-inactive') |
| 45 | + navItems[i].classList.remove('open') |
87 | 46 | } |
88 | 47 | this.style.display = 'none' |
89 | 48 | }) |
|
92 | 51 | function toggleActive (e) { |
93 | 52 | if (this.getAttribute('data-depth') === '1') { |
94 | 53 | var otherNavs = document.querySelectorAll('.nav-item[data-depth="0"]:not(.is-active)') |
95 | | - console.log(otherNavs) |
96 | 54 | for (var i = 0; i < otherNavs.length; i++) { |
97 | 55 | otherNavs[i].classList.add('is-inactive') |
98 | 56 | } |
|
0 commit comments