I have this pop up created that pops up when you scroll to the bottom of the page.
I want to take the same idea but have it pop down from the TOP of the page, and at a specific point on the page (not at the top or bottom, but at a certain div).
Here's the way I am currently creating this pop up:
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() == $(document).height()) {
$('#signup').addClass('show')
} else {
$('#signup').removeClass('show')
}
});
$('#signup').on('click', '.close', function(e) {
e.preventDefault();
$('#signup').removeClass('show')
})
/* popup at end of page */
body {
height: 1000px;
}
/* create a scrollbar for demo purposes */
#signup {
position: fixed;
z-index:100;
width: 100%;
bottom: -50px;
height: 50px;
left: 0;
background-color: green;
transition: bottom .5s linear;
color: white;
font-size: 2em;
text-align: center
}
#signup.show {
bottom: 0;
}
html { height: 2000px; } /* create a scrollbar for demo purposes */
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="signup" class="signup">
<div class="container">
<p class="text-xlg text-center">
Don't have an account yet? Get started here
<a class="btn btn-white btn-outline" href="#">Free Trial</a>
<a class="btn btn-white btn-outline" href="#">Contact Us</a>
</p>
<a href="#" class="close"><i class="fa fa-times text-white"></i></a>
</div>
</div>
So, how can I manipulate this same method to cause a pop-up to drop from the TOP at a certain point in the page. The goal is to create a new nav once you're at a certain spot. **I do not want to create a sticky div. I don't want it to be shown on the screen at all, similar to the pop-up example i included.
ex:
<nav>
Here is the static nav bar
</nav>
<div>
Likely a banner in here
</div>
<div class="new-nav">
Once scrolled to this point, new nav pop up slides down from top.
</div>