I'm hoping someone can help. I'm trying to get some animation on scroll working with a jQuery script I found. I think I've managed to get it to read $ and jQuery as Wordpress runs in NoConflict mode, but so far I am unable to get the script to do anything.
Here is the JS:
jQuery(document).ready(function($) {
$(function() {
var $window = $(window),
win_height_padded = $window.height() * 1.1,
isTouch = Modernizr.touch;
if (isTouch) { $('.revealOnScroll').addClass('.animated'); }
$window.on('scroll', revealOnScroll);
function revealOnScroll() {
var scrolled = $window.scrollTop(),
win_height_padded = $window.height() * 1.1;
// Showed...
$(".revealOnScroll:not(.animated)").each(function () {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded > offsetTop) {
if ($this.data('timeout')) {
window.setTimeout(function(){
$this.addClass('.animated ' + $this.data('animation'));
}, parseInt($this.data('timeout'),10));
} else {
$this.addClass('.animated ' + $this.data('animation'));
}
}
});
// Hidden...
$(".revealOnScroll.animated").each(function (index) {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded < offsetTop) {
$(this).removeClass('.animated .fadeInUp .flipInX .lightSpeedIn')
}
});
}
revealOnScroll();
});
});
I'm not great with jQuery, but any pointer would be great. I'm pretty sure the problem lies within the script and no classes are added or removed.