Struggling to get InteractionObserver to fire only once

Ive got a set of cards in the project section of my portoflio running with InteractionObserver. The cards load in fine, but once you go to the bottom of the page and then go back up, the cards load back in and you can clearly see where. I've tried getting my code to unobserve() once it's finished but I'm not sure what my issue is here. Sorry if my explanation is poor, I have a hard time sometimes! Portfolio: https://www.devjones.space/
2 Replies
vince
vince2y ago
I'm doing something similar right now, I had the same issue and had to remove the .remove(). It's basically saying "if the user is looking at the part that's being observed, add the .fade-in class, if not remove it. So when you scroll away from the element it will remove the .fade-in and do it again when you're looking at it again
Punitor
PunitorOP2y ago
Awesome thanks man. Worked perfectly
Want results from more Discord servers?
Add your server