I want to check if an element is scrolled to top with an offset of ~ 100px.
I´ve got a page with 5 subcontents and 2 classes to make backgrounds. It looks like this:
You have to listen for the scroll event, then check each element against the currently scrolled distance, something like :
$(window).on('scroll', function() {
var scrollTop = $(this).scrollTop();
$('.background1, .background2').each(function() {
var topDistance = $(this).offset().top;
if ( (topDistance+100) < scrollTop ) {
alert( $(this).text() + ' was scrolled to the top' );
}
});
});