Animation popping in and out

I’m looking to make website content appear once you scroll down into the view, and dissapear only when you’re scrolling up out of the view.

An example is this website:

Right now I can play a timeline on viewport and reverse it on exit viewport, is there a good way to use scrolling direction like that website?


Possible starting point to answer your question:
Try an internet search for “scroll direction javascript” - I got a bevy of pertinent hits.