Why is this not working using body? Before it was using window, however i would like this to use body. But when i add this to the code it doesn't work.
here is my fiddle
and here is my code;
$(document).ready(function () {
$('.timeline li .dot:first').addClass("blur");
$('.timeline li .date:first').addClass("blur2");
});
var $window = $('body');
function isScrolledIntoView($elem, $window) {
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
var elements = $('.timeline li .dot');
$('body').on('scroll', function () {
elements.each(function () {
$this = $(this);
if (isScrolledIntoView($this, $window)) {
$this.addClass("blur");
}
else {
$this.removeClass("blur");
}
})
});
var elements2 = $('.timeline li .date');
$('body').on('scroll', function () {
elements2.each(function () {
$this = $(this);
if (isScrolledIntoView($this, $window)) {
$this.addClass("blur2");
}
else {
$this.removeClass("blur2");
}
})
});
it should make the circles bigger as you scroll but currently its not doing it?
edit: previous fiddle, but this does not work in my code;