-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Hi,
First of all thanks for creating this fantastic library. Exactly what I need for my home photo gallery project.
Here is my use case: I load a couple hundred to a couple thousand photo thumbnails to pig.js and I would like to have a great scrolling/viewing experience. However, the images are hosted on a cloud storage provider and I can access them via api requests. Hence, I implemented the api calls to get the links to the images in the urlForSize. Works perfectly.
The problem is that when I scroll quickly to a different part of the image grid, the cloud api server is bombarded with hundreds of requests and it takes a significant amount of time to get the url of the actual images that are on the screen. The wait time can easily be 20-40 sec or more.
Do you have a solution for the above?
With some googling some ideas I could gather:
- Don't call heavy js code on scroll events as there is too many of them. Instead implement a timer and batch/filter the api calls on the timer event and not the scroll event.
- Find a way to only call the external api once scrolling is settled. I don't know how to do it.
- Drop the pending api requests that we no longer need (as we scrolled over them).
You may have a better idea though.
Thanks,
David