I've been playing around with the jquery plugin waypoints. I would like to have this element fade in when is browser view and fade out when not but I haven't been able to figure it out. The element I'm using is an with position: absolute. I'm not sure whether that will effect the script or not.
Here's the JSFiddle http://jsfiddle.net/LvjoLuvx/2/ on what I'm working with. waypoints.js is linked in the external resources.
HTML
<li id="span">
<img class="logo"></img>
</li>
CSS
#span{
height: 2000px;
list-style: none;
}
.logo{
width: 20%;
height: 30%;
background-color: blue;
margin-left: 40%;
position: absolute;
}
JQUERY
$('.logo').waypoint(function(event, direction) {
// Fade in here
$(this).fadeIn(800);
}, {
offset: function() {
// The bottom of the element is in view
return $.waypoints('viewportHeight') - $(this).outerHeight();
}
});