My website has a navigation bar that begins at the bottom left of the page. I would like it to pause 2em from the top of the viewport when scrolling up.
<script>
var mn = $(".main-nav");
mns = "main-nav-scrolled";
$(window).scroll(function() {
if( $(this).scrollTop() > 1000 ) {
mn.addClass(mns);
} else {
mn.removeClass(mns);
}
});
</script>
I am struggling with the formula for setting the distance from the top. Instead of using 1000, I want it to stop 2em
from the top.