Skip to content

Instantly share code, notes, and snippets.

@SebDeclercq
Created April 18, 2019 10:50
Show Gist options
  • Save SebDeclercq/bac2a4c3c184e6565f9d34836cc06ec9 to your computer and use it in GitHub Desktop.
Save SebDeclercq/bac2a4c3c184e6565f9d34836cc06ec9 to your computer and use it in GitHub Desktop.
Testing to change navbar behaviour in creative-bootstrap css/js
<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