Change background colour on scroll
hi all,
i have below code changes background colour when scrolling. there a few problems code below:
1. colour changes on scroll down , not change on scroll up.
2. set more accurate point when colour changes. i.e. set change once anchor comes viewport or change @ 200 vh example. appreciated.
many thanks,
alex
#test{
height: 200vh;
width: 100%;
display: block;
background-color: rgba(255,255,255,1);
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<!--for rgba support. http://pioupioum.fr/sandbox/jquery-color/ -->
<script type="text/javascript" src="https://raw.github.com/pioupioum/jquery-color/master/jquery.color.js"></script>
<!--the magic -->
<script type="text/javascript">
$(document).ready(function(){
$(document).scroll(function(){
if($(this).scrolltop() > 200)
$('#test').animate({backgroundcolor: 'rgba(0,0,0,.9)'}, 1000);
});
});
</script>
if post working example of online, might more help.
nancy o.
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment