Basic intersection observer to trigger events when elements reach determined part of the viewport.
Every line is explained with comments within the code.
Feel free to use it in your projects. The type is set to module in the package.json file so you can import it your project.