Bonjour à tous,
J'ai un souci d'écriture de code. J'ai un menu flottant sur mon bandeau de gauche et arrivé au footer, ce même menu lui passe dessus. J'aimerais pouvoir préciser dans le code javascript qu'arrivé sur mon id="footer", le menu flottant s'arrête et ne chevauche pas le footer. Suis-je assez clair ? Voici mon code javascript :
Merci d'avance pour vos réponses
J'ai un souci d'écriture de code. J'ai un menu flottant sur mon bandeau de gauche et arrivé au footer, ce même menu lui passe dessus. J'aimerais pouvoir préciser dans le code javascript qu'arrivé sur mon id="footer", le menu flottant s'arrête et ne chevauche pas le footer. Suis-je assez clair ? Voici mon code javascript :
/* SideBar collant */
$(function(){
$('.sticky').each(function(){
var parent = $(this).parent();
var dTop = $(this).offset().top;
var elem = $(this);
var stickyHeight = this.clientHeight;
parent.css('position','relative');
elem.css('position','absolute');
$(window).scroll(function(){
var scroll = scrollY();
var aboutMeHeight = document.getElementById('aboutMe').clientHeight
if(aboutMeHeight != 0){
// 15 : see aboutMe.content padding bottom
aboutMeHeight += 15;
}
var dTopWithAboutMeHeight = dTop + aboutMeHeight;
//alert(dTopWithAboutMeHeight);
if(document.height-scroll<stickyHeight+dTopWithAboutMeHeight){
var footerTop = document.height - document.getElementById('footer').clientHeight;
elem.stop().animate({top:footerTop-stickyHeight-dTopWithAboutMeHeight},500);
} else if(scroll>dTopWithAboutMeHeight){
elem.stop().animate({top:scroll-parent.offset().top+20},500);
}else{
elem.stop().animate({top:dTopWithAboutMeHeight-parent.offset().top},500)
}
});
});
});
/* Return the position of the top */
function scrollY(){
scrOfY=0;
if(typeof( window.pageYOffset ) == 'number' ){
//Netscape compliant
scrOfY = window.pageYOffset;
}else if (document.body && (document.body.scrollTop)){
//DOM compliant
scrOfY = document.body.scrollTop;
}else if (document.documentElement && (document.documentElement.scrollTop)){
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
}
return scrOfY;
}
Merci d'avance pour vos réponses