Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Nav icon does not update back to the menu icon on nav item click #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions assets/js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,33 @@
}
}

// Full screen nav open on click
// Full screen nav open/close on nav icon click
$('.nav-icon').addEventListener('click', function() {
toggleNav()
})

// Full screen nav close on nav item click
$$('.nav-full a').forEach(function(links) {
links.addEventListener('click', function() {
toggleNav()
})
})

// Full screen nav toggle
function toggleNav() {
$$('.nav-full, main').forEach(function(el) {
el.classList.toggle('active')
})
if (menuActive) {
this.querySelector('img:nth-of-type(1)').style.display = 'inline-block'
this.querySelector('img:nth-of-type(2)').style.display = 'none'
$('.nav-icon').querySelector('img:nth-of-type(1)').style.display = 'inline-block'
$('.nav-icon').querySelector('img:nth-of-type(2)').style.display = 'none'
menuActive = false
} else {
this.querySelector('img:nth-of-type(1)').style.display = 'none'
this.querySelector('img:nth-of-type(2)').style.display = 'inline-block'
$('.nav-icon').querySelector('img:nth-of-type(1)').style.display = 'none'
$('.nav-icon').querySelector('img:nth-of-type(2)').style.display = 'inline-block'
menuActive = true
}
})

// Full screen nav close on click
$$('.nav-full a').forEach(function(links) {
links.addEventListener('click', function() {
$$('.nav-full, main').forEach(function(el) {
el.classList.toggle('active')
})
})
})
}

// Fix logoBig drawing over nav when click on logoSmall while nav open
$('.logo').addEventListener('click', function() {
Expand Down