Skip to content

Commit

Permalink
Merge pull request orizens#235 from adrienverge/fix-issue-198
Browse files Browse the repository at this point in the history
Fix delay for `scrolled` callback
  • Loading branch information
orizens authored Feb 21, 2018
2 parents ed90961 + f979597 commit 678ea1d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/services/scroll-register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ export function createScroller(config: Models.IScroller) {
}

export function attachScrollEvent(options: Models.IScrollRegisterConfig): Observable<{}> {
return Observable
.fromEvent(options.container, 'scroll')
.sampleTime(options.throttle);
let obs = Observable.fromEvent(options.container, 'scroll');
// For an unknown reason calling `sampleTime()` causes trouble for many users, even with `options.throttle = 0`.
// Let's avoid calling the function unless needed.
// See https://github.com/orizens/ngx-infinite-scroll/issues/198
if (options.throttle) {
obs = obs.sampleTime(options.throttle);
}
return obs;
}

export function toInfiniteScrollParams(
Expand Down

0 comments on commit 678ea1d

Please sign in to comment.