I’m new and this is my first question…
I’m developing a website for my customer and I’ve implemented jQuery with a simple script:
Code:
var fixed = false;
$(window).scroll(function() {
if( $(window).scrollTop() + $(window).height() == $(document).height()) {
if( !fixed ) {
fixed = true;
$('.return').fadeIn("slow");
}
} else {
if( fixed ) {
fixed = false;
$('.return').fadeOut("slow");
}
}
});
Where is the problem?
Well in the homepage all is ok no errors, when I scroll until the end of the page, the div with the link for return to top appears and when I scoll to top the div disappear.
In the second page I’ve implemented the same structure of the page, I’ve added only different text and a custom Google Maps with her API. What happens now? The script work on the contrary, when I scroll until the end of the page the div disappears and when I scroll to top appears.
What is the mistake?
It could be that fixed is a variable used by something else on that page. Sounds like it’s working in reverse (so fixed is being set to true before you scroll down).
Assuming this is for some sort of page scroll-to-top function, wouldn’t it be better to have the divider appear after the user has scrolled down a little, but not right to the end?