JSFiddle - React, Tailwind, and code Playground
HTML
<div class="main"></div>
<footer class="nav-down">123</footer>
CSS
* {
margin:0;
padding:0;
color: transparent;
}
.main {
width:100%;
height:1500px;
}
.nav-down {
bottom: -40px;
}
footer {
-webkit-backface-visibility: hidden;
background: #000;
height: 40px;
position: fixed;
bottom: 0;
transition: bottom 0.2s ease-in-out;
width: 100%;
z-index: 1000;
border-top:1px solid #000;
}
JavaScript
// Hide Footer on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('footer').outerHeight();
function IsBottom() {
return $(window).scrollTop() == ($(document).height() - $(window).height());
}
$(window).scroll(function (event) {
didScroll = true;
if (IsBottom()) {
$('footer').removeClass('nav-down').addClass('nav-up');
}
});
setInterval(function () {
if (didScroll && !IsBottom()) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if (Math.abs(lastScrollTop - st) <= delta) return;
if (st > lastScrollTop && st > navbarHeight) {
$('footer').removeClass('nav-up').addClass('nav-down');
} else {
if (st + $(window).height() < $(document).height()) {
$('footer').removeClass('nav-down').addClass('nav-up');
}
}
lastScrollTop = st;
};