Skip to content

urlForSize triggered too many times for api calls during fast scrolling #36

@Sherlock1979

Description

@Sherlock1979

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:

  1. 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.
  2. Find a way to only call the external api once scrolling is settled. I don't know how to do it.
  3. Drop the pending api requests that we no longer need (as we scrolled over them).

You may have a better idea though.

Thanks,
David

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions