Open karol-depka opened 3 years ago
It should be a separate component from the manual-load-more-via-button (
If rootMargin
(in px or smth like 100%
(extra screen-height)) causes problems, then we can just increase the number-of-items-to-load-ahead-of-time, to have more buffer.
Let's not forget to destroy/unsubscribe the IntersectionObserver, in ngOnDestroy()
, to avoid performance/memleak problem.
keep in mind: trackBy
Let's first try: https://github.com/orizens/ngx-infinite-scroll in separate list/scroll implementation sub-component (switchable via options component)
Example with IntersectionObserver:
https://netbasal.com/build-an-infinite-scroll-component-in-angular-a9c16907a94d
https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin (for buffer - can try smth like 100% instead of px)
https://github.com/gatsbyjs/gatsby/issues/14033
https://www.sitepoint.com/intersectionobserver-api/ (OLD)