DEV Community

Discussion on: How to create a scroll to top button with vanilla JS & CSS

Collapse
 
link2twenty profile image
Andrew Bone

A little trick you can do to remove the overhead of a scroll listener is make trigger line and use IntersectionObserver to see if it's on the screen or not.

Something like this