This is a simple demo showing the working of scroll-to-bottom-to-accept functionality; generally found in TnC page on sites. This functionality was built using vanilla JavaScript.
Things I learned while building this:
- IntersectionObserver() constructor function and its powerful usage,
- Why not to use scrollTop and scrollHeight to achieve same functionality (Answer: It's unnecessary nowadays),
- Logical yet surprising things at first sight, e.g., scroll events do not bubble up,
- And, finally, how to put everything together.