I have the following function which applies a class (header-hide/header-show) to a div based on user scroll.
$(document).ready(function($) {
// adjust this number to select when your button appears on scroll-down
var offset = 75,
// bind with the button link
$animation = $('header');
// apply animation
$(window).scroll(function() {
($(this).scrollTop() > offset) ? $animation.addClass('header-hide').removeClass("header-show"):
$animation.addClass('header-show').removeClass("header-hide");
});
.header-hide {
opacity: 0;
visibility: hidden;
}
.header-show {
opacity: 1;
visibility: visible;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header class="header-show">
<div>
<h3>header</h3>
<h1>subHeader</h1>
</div>
</header>
I want to do a similar thing to a different div (footer-show/footer-hide added to 'footer'), with a different offset (300). I want to do this efficiently so I don't want to copy and run a copy of the function and was hoping to integrate it into this one. but can't get it to work.