Created
November 24, 2017 21:58
-
-
Save bob-lee/2f83214040f99790b4ff819e0d84cf93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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