Ciao a tutti,
ho un div che segue lo scroll in questo modo:
codice:
jQuery(document).ready(function () {
var el=jQuery('#news_right_cont');
var elpos=el.offset().top;
var gap=174;
jQuery(window).scroll(function () {
var y=jQuery(this).scrollTop();
if(y<elpos){el.stop().animate({'top':174},0);}
else{el.stop().animate({'top':y-elpos + gap},0);}
});
});
vorrei però che si fermi ad una determinata altezza dal fondo pagina dato che avrei un footer di 465px..
avrei pensato di creare una variabile visibleFoot e una elheight
e creare una condizione in questo modo ma senza risultato..
codice:
jQuery(document).ready(function () {
var el=jQuery('#news_right_cont');
var elpos=el.offset().top;
var elheight=el.height();
var gap=174;
jQuery(window).scroll(function () {
var y=jQuery(this).scrollTop();
var yb=jQuery(this).scrollBottom();
var visibleFoot = 465 - jQuery(this).scrollBottom();
if(y<elpos){el.stop().animate({'top':174},0);}
else if(visibleFoot<elheight){el.stop().animate({'bottom':visibleFoot + "px"},0);}
else{el.stop().animate({'top':y-elpos + gap},0);}
});
});
Dove sbaglio?
Grazie