I'm trying to add classes when the user scrolls up and down in order to show 2 css animations.
It works well if I'm only using the scroll down animation, but its inconsistent when I use both the scroll up and scroll down animations.
I'm having problems getting animations to fire multiple times in a row. As in- scroll down pause, scroll down pause, scroll up pause, scroll up pause.
Here's a jsFiddle to better demonstrate the problem.
and the code-
(function () {
var previousScroll = 0;
$(window).scroll(function () {
var currentScroll = $(this).scrollTop();
if (currentScroll > previousScroll) {
//down scroll code
$("#repel").removeClass("climb");
$("#repel").addClass("repel").delay(1150).queue(function (next) {
$(this).removeClass("repel");
next();
});
} else {
// upscroll code
$("#repel").removeClass("repel");
$("#repel").addClass("climb").delay(1000).queue(function (next) {
$(this).removeClass("climb");
next();
});
}
previousScroll = currentScroll;
});
}());
getting animations to fire multiple times. I don't really see any animation in the jsFiddle?