I want to do a simple effect, which would be to apply a animate
effect to a div
, increasing its height after scrolling the page, and when the page rolled to the top again, that div
would return to style initial.
CSS
<style>
.geral-boxes{
width: 100%;
float: left;
}
.box1,.box2,.box3{
width: 100%;
float: left;
height: 500px;
}
.box1{
background-color: #fff;
}
.box2{
background-color: #fff;
}.box3{
background-color: #fff;
}
.geral-boxes{
width: 100%;
float: left;
}
.laranja{
width: 100%;
float: left;
}
.scroll-aparecer{
width: 50px;
float: left;
height: 0px;
background-color: #000;
}
SCRIPT
$(document).ready(function(){
$(window).on('scroll', function() {
if($(window).scrollTop() > 200) {
$('.scroll-aparecer').animate({
height:"100px"
}, 1000); /*Defina aqui o tempo em milisegundos */
}else{
$('.scroll-aparecer').animate({
height:"0"
}, 1000); /*Defina aqui o tempo em milisegundos */
}
});
});
HTML
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="scroll-aparecer"></div>
What is the best way to do this?