Forum Moderators: open
$(document).ready(function() {
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 144) {
$( "#navbarCustom" ).animate({
opacity: 0
}, 377, function() {
//alert("animation complete!");
});
}
});
});
$(document).ready(function() {
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 144) {
$( "#navbarCustom" ).animate({
opacity: 0
}, 377, function() {
//alert("animation complete!");
});
}
else {
$( "#navbarCustom" ).animate({
opacity: 1
}, 377, function() {
//alert("animation complete!");
});
}
});
});
Let me see if I understand what you've got there now. Suppose you have the following:
document height of 1000px
window height (viewport) of 500px.
If the user scrolls 10px down the page, then your calculation will do this:
if (10 + 500 > 1000 - 144)
so
if (510 > 856) { opacity: 0 }
So in this particlar case, the user must scroll down 357px before the opacity will be set to zero. At that point, the user will be 143px away from the bottom, won't they?