As is seen on a lot of sites currently, I would like to do something with an element when it comes into the view port or 100px from the viewport etc.
I have been searching for ages but so far nothing has worked.
I have a list of elements which are 500px high and 100% width. Im okay with the animation etc and what Im going to do with them, just need a bit of help triggering then when they are coming into view.
My aim is to give elements a class of animation-element and then be able to use that class to check if its in view.
Pseudo code:
$(window).on('scroll', function() {
if (element is in the viewport) {
$(this).doSomething();
}
});
Seems lazy of me but I have been looking for too long without success.
Any previous attempts have just always triggered on when constant scrolling so even if the elements are no in the viewport and i'm setting a console log i'll have 100's of logs when scrolling a tiny bit.