Hi team, Any way for me to fetch a specific number of results and lazy load the rest as a user scrolls? or should i upgrade my plan ? The API returns over 22,000+ products for a tool i'm building. I upgrade to scale up plan, but still having issues.
Lucas G
3 months ago
Aug 26, 2024, 3:21 AM
This is solved now right?
Just infinite scroll next to check off
โค๏ธ1
TCG.Store
3 months ago
Aug 26, 2024, 2:06 PM
Yeah this is solved ๐-- just need to figure out the infinite scroll piece. Currently experimenting now to see how i can tackle this
function infiniteScroller (args, ctx) { const observer = new IntersectionObserver((entries, observer) => { for (const entry of entries) { if (entry.isIntersecting) { ctx.triggerActionEvent('loadNextPage', true); } } }); const scrollSentinel = document.getElementById("scroll-sentinel"); observer.observe(scrollSentinel); }
๐1
๐ฅ1
๐ซถ1
The loadNextPage event would trigger your API/pagination workflow
Which would depend on your setup
Ah, I should clarify. In the code you'll see a 'scroll sentinel'
Lucas G
3 months ago
Aug 28, 2024, 6:16 PM
I placed an empty div after the main content div which has that as its id
Basically, when the page hits that div it triggers your pagination workflow
nathandh
3 months ago
Aug 29, 2024, 12:56 AM
What is the {ctx} parameter?
TCG.Store
3 months ago
Aug 29, 2024, 12:57 AM
Thank you so much for sharing this @Lucas G and no worries on the delay. This is beyond super helpful. Iโm going to give this a try when I get back home! ๐ก
needtheanswers
3 months ago
Aug 30, 2024, 8:14 AM
Thanks for sharing the code @Lucas G. Would be curious to know how your page setup looks like. Would you mind sharing your project link?