Hello
I have a grid of, let's say 100 items (.grid-post) and I use the batch() method of scrollTrigger this way:
ScrollTrigger.batch(".grid-post", {
onEnter: elements => {
gsap.from(elements, {
y: 60,
autoAlpha: 0,
stagger: 0.1,
duration: 0.5,
});
},
once: true
});
It works just fine when you first load the page and start scrolling down.
However when you have scrolled further down the page and then you hit refresh, since the browser remembers your scroll position, you have to wait for all the animations to happen from the beginning of the grid causing a big delay in actually viewing the items that are in viewport.
Is there any way of using the isInViewport() with the batch() method to just limit the batch with elements that are in viewport downwards? All the previous ones can be shown without animation as i'm not interested in onEnterBack animations.
Unfortunately, I cant give you a CodePen as it doesn't keep the scroll position when you hit refresh on the browser and I hope you understand what I'm after.
Any help would be appreciated as I'm quite fresh to GSAP.
Thanks!