Skip to content

Instantly share code, notes, and snippets.

@bob-lee
Created November 24, 2017 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bob-lee/2f83214040f99790b4ff819e0d84cf93 to your computer and use it in GitHub Desktop.
Save bob-lee/2f83214040f99790b4ff819e0d84cf93 to your computer and use it in GitHub Desktop.
return this.http.get(`${API}/${path}`).toPromise().then((snapshot) => {
this.list = [];
// prepare a list for intersection observer
this._indexToObserve = 0;
const items = snapshot.json();
this.list = items.reverse().map((item, index) => {
/* provide 2 additional properties for each image:
toLoad: boolean, the component to load image,
index: number, the component to call observe(item) on image loaded
*/
item.toLoad = index < (this.indexToObserve + INTERSECT_PAGESIZE);
item.index = index;
return item;
});
return this.list;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment