Focus User On view of Objects
Focus User On view of Objects CSS3, Animate, JQuery
by Andrew Pougher
HTML
<link rel="stylesheet" href="https://daneden.github.io/animate.css/animate.min.css">
<div id="container">
<h2>Focus User On view of Objects</h2>
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<img class="post img-rounded" src="http://placehold.it/250x250/345368/&text=Andrew">
<div class="post">NONE IMAGE</div>
</div>
<script>
/* http://bit.ly/ARP71 */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-4809804-1', 'auto');
ga('send', 'pageview');
</script>
CSS
.post {
width: 250px;
height: 250px;
background: #345368;
margin: 10px;
opacity:0.3
}
.selected {
background: green;
opacity:1
}
JavaScript
$(function () {
$(window).bind('scroll', function () {
$('.post').each(function () {
var post = $(this);
var position = post.position().top - $(window).scrollTop();
if (position <= 124) {
post.addClass(' selected animated fadeIn');
} else {
post.removeClass(' selected fadeIn');
}
});
});
});