I've implemented a top div on my page that houses contact details and social media links. I've managed to hide it during scrolling and make it reappear when reaching the top of the page. However, I'm hoping to smoothen this transition with a slide-up and slide-down effect, which I've struggled to achieve so far. Below is the current code snippet:
(function($) {
"use strict";
function mainNavbar() {
if ($('#main_navbar').length) {
$('#main_navbar').affix({
offset: {
top: 10,
bottom: function() {
return (this.bottom = $('.footer').outerHeight(true))
}
}
});
}
}
mainNavbar();
})
.top_header_area {
background: #333333;
}
.top_header_area .top_nav li a {
font: 400 14px/50px "Roboto", sans-serif;
color: #fff;
padding: 0;
padding-left: 30px;
}
.top_header_area .top_nav li a i {
color: #cc0033;
font-size: 18px;
padding-right: 10px;
}
.top_header_area .top_nav li a:hover,
.top_header_area .top_nav li a:focus {
background-color: transparent;
color: #cc0033;
}
.top_header_area .top_nav li:first-child a {
padding: 0;
}
.top_header_area .social_nav {
margin: 0;
padding-top: 12px;
}
.top_header_area .social_nav li a {
font-size: 14px;
color: #fff;
padding: 0;
text-align: center;
height: 24px;
width: 24px;
border-radius: 50%;
margin-left: 10px;
}
.top_header_area .social_nav li a i {
line-height: 24px;
}
.top_header_area .social_nav li a:hover,
.top_header_area .social_nav li a:focus {
background: #cc0033;
color: #333333;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section id="top" class="top_header_area">
<div class="container">
<ul class="nav navbar-nav top_nav">
<li><a href="#"><i class="fa fa-phone"></i>317-328-8492</a></li>
<li><a href="#"><i class="fa fa-envelope-o"></i><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5d34333b321d3c293e34333e73333829">[email protected]</a></a></li>
</ul>
<ul class="nav navbar-nav navbar-right social_nav">
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
</ul>
</div>
</section>
<div class="main">
<p>Here is some sample text<br>
Scroll me<br></p>
</div>