angular-infinite-scroller icon indicating copy to clipboard operation
angular-infinite-scroller copied to clipboard

how to scroll using window scroll

Open lomoonmoonbird opened this issue 7 years ago • 7 comments

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 :)

lomoonmoonbird avatar Feb 02 '18 10:02 lomoonmoonbird

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.

ashwin-sureshkumar avatar Mar 22 '18 16:03 ashwin-sureshkumar

Anyone figured out how to do this?

JoseClimaco avatar May 08 '18 14:05 JoseClimaco

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]))
  }

JoseClimaco avatar May 09 '18 09:05 JoseClimaco

How to scroll to right and append data on right?

divya2512 avatar May 09 '18 19:05 divya2512

@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.

ashwin-sureshkumar avatar May 10 '18 19:05 ashwin-sureshkumar

@JoseClimaco can you post a full example?

logicalsisufaj avatar Jul 24 '18 09:07 logicalsisufaj

@ashwin-sureshkumar sorry for late, i would give it a try. thanks

lomoonmoonbird avatar Jul 26 '18 05:07 lomoonmoonbird