I have a sticky header which is fixed on scroll using jQuery when reaching a height of 160.
$(window).scroll(function()
{
if( $(window).scrollTop() > 160)
{
$('.dark-menu').addClass('stickyNav');
$('header').addClass('mainHeaderFixed');
$(".menu-second-menu-container").hide();
$(".menu-first-menu-container").addClass('new-end');
$("a.main-logo").hide();
$("a.small-logo").show();
$(".bp-phone").addClass("stickyNumber");
$("img.telephoneIconHeader").addClass("stickyImg");
$("a.topHeaderMailto").addClass("stickyaa");
}
else
{
$('.dark-menu').removeClass('stickyNav');
$("a.topHeaderMailto").removeClass("stickyaa");
$('header').removeClass('mainHeaderFixed');
$(".menu-second-menu-container").show();
$(".menu-first-menu-container").removeClass('new-end');
$("a.main-logo").show();
$("a.small-logo").hide();
$(".bp-phone").removeClass("stickyNumber");
$("img.telephoneIconHeader").removeClass("stickyImg");
}
});
This is fine for showing / hiding elements, but I want the whole sticky nav and the backbar to animate on scroll.
I have tried to apply CSS on the header sections:
-webkit-transition: height 5s;
-moz-transition: height 5s;
transition: height 5s;
But this is not working. What can I do to make this animate on scroll?
Here is my site:
http://insurancefocus.bemediadev.com.au/
Here is what I would like to achieve: