Reputation: 749
can someone help me here, I need this function to stop at top: -70px; also, when you click it anytime after its stopped it will pop back open but I think I can do that part, main question is how to stop the function I have when it reaches -70px.
$(window).scroll(function () {
var topMove = -1 * (620 * $(this).scrollTop() / $('body').height());
$('.nav').css({ top: Math.max(topMove) });
});
Thanks!
Upvotes: 0
Views: 64
Reputation: 24375
Is this what you are after?
I had to add console.log(topMove);
to see what value your variable was producing. In fact, it was a negative value.
I then added the following to only run when topMove
is more than or equal to -70
.
if(topMove >= -70) {
$('.nav').css({ top: Math.max(topMove) });
}
Upvotes: 1