I'm making a website, which has some animations, and when I get to the bottom of the site for the first time, should trigger an event where the page returns to the top, but in the following times (without reloading) the event will not happen again.
How could I do this?
HTML:
<header>
</header>
<div id="content">
<div id="broca">
</div>
</div>
<footer>
</footer>
CSS:
header, footer{
display:block;
height:200px;
background:red;
width:100%;
}
#content{
display:block;
width:100%;
height:1500px;
background:blue;
}
#broca{
width:50px;
height:0;
background:#000;
}
JQuery:
$(function(){
$(window).scroll(function() {
var $broca = $('#broca');
var st = $(this).scrollTop();
if (st > $broca.height()){
$broca.clearQueue().animate({
height: st } , 1000);
}
if( st == 0 ) {
} else {
$broca.show();
}
}).scroll();
})