Skip to content

Commit

Permalink
throttle time option added to observe method
Browse files Browse the repository at this point in the history
  • Loading branch information
alisahinozcelik committed Nov 19, 2018
1 parent 1b54f39 commit eb21b0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ observer.remainingX.subscribe(position => {
```

## Performance
By default, scroll-manager throttles scroll events for every 90ms.
By default, scroll-manager throttles scroll events in every 90ms for performance prospects

If you want to capture all events use `const observer = scrollManager.observe(target, 0);`

Expand Down
5 changes: 3 additions & 2 deletions src/scroll-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ export class ScrollManager {
* ```
* * * *
* @param target Scroll target
* @param throttleTime Time to throttle the scroll events
*/
public observe(target: ScrollableContent): ScrollObserver {
public observe(target: ScrollableContent, throttleTime = this.observerThrottleTime): ScrollObserver {
if (!this._buffer.has(target)) {
this._buffer.set(target, new ScrollObserver(target, this.observerThrottleTime));
this._buffer.set(target, new ScrollObserver(target, throttleTime));
}
return this._buffer.get(target);
}
Expand Down

0 comments on commit eb21b0e

Please sign in to comment.