scroll from top trigger anim
by lovromar
HTML
<div id='toTop'>To The Top!</div><div id='toBot'>To The Bottom!</div><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
CSS
#toTop {
padding: 5px 3px;
background: #000;
color: #fff;
position: fixed;
top: 0;
right: 5px;
display: none;
}
#toBot {
padding: 5px 3px;
background: #000;
color: #fff;
position: fixed;
bottom: 0;
right: 5px;
display: none;
}
JavaScript
/*$(window).scroll(function() {
if ($(this).scrollBottom() <= 300) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});*/
if ($(window).height() < $(document).height()) {
$('div.#toBottom').show();
}
$(window).scroll(function() {
if ($(window).scrollTop() >= 333) {
$('div#toTop').show();
} else {
$('div#toTop').hide();
}
if ($(window).scrollTop() + $(window).height() >= $(document).height() - 333) {
$('div#toBot').hide();
} else {
$('div#toBot').show();
}
});