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