Right now, each book fades in when they touch the edge of the screen. It works, but people may not be able to see the animation if they don’t scroll fast enough.
We can improve the interaction by fading in each book slightly later, say around 10% from the bottom of the screen.
But we created another problem. Books will now fade out before they reach the bottom of the screen.
Fixing the fade-out problem
The easiest way to fix this problem is to create a second Intersection Observer. We’ll use the first Intersection to add is-visible, and the second Intersection observer to remove is-visible.
First, let’s rename the first observer to incomingObserver.
We’ll create a second observer to fade out books. Let’s call this second observer outgoingObserver. The trick here is to leave rootMargin to its default values.