You just need to add one more condition in the onscroll
event:
if(currentScrollPos === 0) {
document.getElementById("navbar").style.backgroundColor = 'transparent';
} else {
document.getElementById("navbar").style.backgroundColor = 'rgb(27,53,52)';
}
================================================
================================================
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if(currentScrollPos === 0) {
document.getElementById("navbar").style.backgroundColor = 'transparent';
} else {
document.getElementById("navbar").style.backgroundColor = 'rgb(27,53,52)';
}
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-150px";
}
prevScrollpos = currentScrollPos;
}
<div class="container-fluid nav-padding" id="navbar">
<div class="row">
<div class="col-12">
<nav>
<div class="d-flex">
<div class="col">
<span class="nav-left-text">west end</span>
</div>
<div class="col text-right">
<button onClick="document.getElementById('rego').scrollIntoView();" class="register-btn-top">register <span class="d-none d-sm-inline d-lg-inline">now</span></button>
</div>
</div>
</nav>
</div>
</div>
</div>