Currently, I am working on creating a footer that remains fixed at the bottom of the user's screen regardless of the screen size. However, I also want the header to transition from a fixed position to being part of the page when the user scrolls down. While I am new to JavaScript, I have experimented with different solutions like the one below:
$(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function (e) {
var theEvent = e.originalEvent.wheelDelta || e.originalEvent.detail * -1;
if (theEvent / 120 > 0) {
if ($(window).scrollTop() == 0) {
$("#content_under_fixed_footer").hide();
}
} else {
if ($(window).scrollTop() < $(document).height() - $(window).height()) {
$("#content_under_fixed_footer").fadeIn(2000);
$(".fixed_header").css("position", "relative");
}
}
});
However, I have noticed that the trigger is not optimal. It seems to work better on smaller screens where there is more scrolling involved, but on larger screens, it doesn't always perform as expected. I need to finalize this by today and would greatly appreciate any guidance or alternative solutions. Thank you!