angular-infinite-scroller
angular-infinite-scroller copied to clipboard
how to scroll using window scroll
your example is scrolling in a div with overflow:scroll that wrap in a container,what if i want to use window scroll to infinite load page , how could do that, thanks in advance :)
Sorry for the delayed reply. Right now the scroll listener is on the container, you can pass in a value to listen for window scroll and modify the directive.
Anyone figured out how to do this?
To anyone wanting to use window scroll instead of container you'll have to make the following changes:
private registerScrollEvent() {
this.scrollEvent$ = Observable.fromEvent(window, 'scroll'); // change to window
}
private streamScrollEvents() {
this.userScrolledDown$ = this.scrollEvent$
.map((e: any): ScrollPosition => ({
sH: e.target.body.scrollHeight, // instead get scrollHeight of body
sT: window.pageYOffset, // instead get pageYOffset of window
cH: e.target.body.clientHeight // instead get clientHeightof body
}))
.pairwise()
.filter(positions => this.isUserScrollingDown(positions) && this.isScrollExpectedPercent(positions[1]))
}
How to scroll to right and append data on right?
@JoseClimaco - Thank you so much. This is great would you be able to send a PR ? I am going to update the blog with stackblitz as well.
@JoseClimaco can you post a full example?
@ashwin-sureshkumar sorry for late, i would give it a try. thanks