<div id="title-box">
<div class="title">Title</div>
</div>
<div id="gallery">
<div class="gallery-image"></div>
<div class="gallery-image"></div>
<div class="gallery-image"></div>
<div class="gallery-image"></div>
</div>
<div id="text-box">
<div class="text">
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin...
</div>
</div>
I tried various jQuery plugins, but I could not get the desired result. I would like to add a class to the body when the "gallery" element is visible in the viewport, and to remove a class in the body when the "gallery" item is no longer visible.
I'm new to jQuery.