DEV Community


Discussion on: Introduction to scroll animations with Intersection Observer

epresas profile image

Awesome! I usually use intersection observer for lazy loading of images or to play/pause videos when they enter the viewport... But this helps me to get rid of jquery for tos "reveal animations"... One thing I could suggest is add cleanup, when the target enters the viewport, remove the current image from the list of observable elements.... Or once you finish your work, disconnect it, and when the array of observables is empty, the garbage collector will remove the IO... Great post! I will "borrow" this idea for sure

ljcdev profile image
ljc-dev Author

Glad u find it useful and thanks a ton for the feedback Epresas πŸ˜ƒ!! Yep, u could also use AOS for those reveal animations if u don't feel like writing the js.
U're right, I didn't think about adding a cleanup. I should call unobserve or disconnect after the animation has been triggered πŸ‘Œ. Feel free to borrow and show me if u have better ideasπŸ˜‰.