orizens / ngx-infinite-scroll

Infinite Scroll Directive for Angular
https://www.npmjs.com/package/ngx-infinite-scroll
MIT License
1.23k stars 223 forks source link

make [scrollWindow]="false" by default #354

Closed ghost closed 2 months ago

ghost commented 4 years ago

Expected Behavior

suggestion/improvement I think, mostly we use infinite-scroll directive, we want to listen exactly on this element not on the window object itself, so it would be better to be like this by default, and not adding [scrollWindow]="false" every time

Actual Behavior

By default, it is attached to the window object

Possible Solution

Steps To Reproduce / Demo (if applicable)

[ ] Please share a stackblitz or plunkr demo reproducing this issue

Context

Your Environment

FredUK commented 4 years ago

Ah! You helped me solve the problem I was having for the past 30 minutes ..I just couldn't figure out why my (scroll) event wasn't triggering at all.. That was the reason :+1:

orizens commented 3 years ago

@lukaonik that would be a breaking change for millions of projects that are using ngxis. i can think of exporting a second component which would set that value to false by default. i'm suggesting:

<ngx-infinite-scroll-container
      infiniteScroll
      [infiniteScrollDistance]="scrollDistance"
      [infiniteScrollUpDistance]="scrollUpDistance"
      [infiniteScrollThrottle]="throttle"
      (scrolled)="onScrollDown()"
      (scrolledUp)="onUp()"
    >
      <section class="content">
        <div *ngFor="let i of array()">
          {{ i }}
        </div>
      </section>
    </ngx-infinite-scroll-container>

for future reference - might be useful to handle this with a HOC https://stackblitz.com/edit/adv-ng-patterns-03a-compound-comp-inject-parent-v3end5?file=app%2Ftoggle%2Ftoggle.component.ts

orizens commented 3 years ago

@lukaonik try out ngx-infinite-scroll@10.0.9-next with the above component:

<ngx-infinite-scroll-container
      infiniteScroll
      [infiniteScrollDistance]="scrollDistance"
      [infiniteScrollUpDistance]="scrollUpDistance"
      [infiniteScrollThrottle]="throttle"
      (scrolled)="onScrollDown()"
      (scrolledUp)="onUp()"
    >
<generate-scrollable-content-here />
</ngx-infinite-scroll-container>

also - please set the infinite-scroll element class with a height:

.ngxisc {
  height: 300px;
  overflow: auto;
}