$(function() { var $window = $(window), win_height_padded = $window.height() * 1.1, isTouch = Modernizr.touch; if (isTouch) { $('.revealScroll').addClass('animated'); } $window.on('scroll', revealScroll); function revealScroll() { var scrolled = $window.scrollTop(), win_height_padded = $window.height() * 1.1; $(".revealScroll:not(.animated)").each(function () { var $this = $(this), offsetTop = $this.offset().top; if (scrolled + win_height_padded > offsetTop) { if ($this) { window.setTimeout(function(){ $this.addClass('animated ' + $this.data('animation')); }, parseInt($this)); } else { $this.addClass('animated ' + $this.data('animation')); } } }); } revealScroll(); });