<div class="fixed-bar">...</div>
.fixed-bar {
transition: 0.7s ease;
transition-property: transform, box-shadow;
height: 50px;
position: fixed;
left: 0;
top: 0;
width: 100%;
z-index: 100;
transform: translateY(-100%);
}
.fixed-bar.isShown {
box-shadow: 0 0 10px black;
transform: translateY(0);
}
const fixedBar = document.querySelector('.fixed-bar');
const toggleBar = function () {
let isShown = window.pageYOffset > window.innerHeight / 2;
fixedBar.classList.toggle('isShown', isShown);
}
toggleBar();
window.addEventListener('scroll', toggleBar);
Демо: