Created
April 18, 2019 10:50
-
-
Save SebDeclercq/bac2a4c3c184e6565f9d34836cc06ec9 to your computer and use it in GitHub Desktop.
Testing to change navbar behaviour in creative-bootstrap css/js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
class NavBarCustomizer { | |
constructor() { | |
this.navbar = document.querySelector('#mainNav'); | |
this.gray = '#212529'; | |
this.white = '#ffffff'; | |
} | |
custom() { | |
if (! document.querySelector('.masthead')) { | |
if (this.navbar.classList.contains('navbar-scrolled')) { | |
for (let fa of this.navbar.querySelectorAll('.fas')) { | |
fa.style.color = this.gray; | |
} | |
} | |
else { | |
} | |
} | |
else { | |
if (! this.navbar.classList.contains('navbar-scrolled')) { | |
for (let fa of this.navbar.querySelectorAll('.fas')) { | |
fa.style.color = this.gray; | |
} | |
} | |
} | |
} | |
} | |
window.addEventListener('load', () => { | |
let customizer = new NavBarCustomizer(); | |
customizer.custom(); | |
document.addEventListener('scroll', () => { | |
customizer.custom(); | |
}); | |
// document.querySelector('#mainNav').classList.add('navbar-scrolled') | |
}, true); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment