DEPRECATED - Please Use The New NGX-Infinite-Scroll
Angular Infinite Scroll
Inspired by ng-infinite-scroll directive for angular (> 2).
Supports in Angular > +2, 4
Angular Consulting Services
- consulting to companies and startups on how to approach code in their projects and keep it maintainable.
- I provide project bootstrapping and development - while afterwards, I integrate it on site and guide the team on it.
npm install angular2-infinite-scroll --save
Currently supported attributes:
- infiniteScrollDistance<number> - (optional, default: 2) - should get a number, the number of viewport lenghts from the bottom of the page at which the event will be triggered.
- infiniteScrollUpDistance<number> - (optional, default: 1.5) - should get a number
- infiniteScrollThrottle<number> - (optional, default: 300) - should get a number of milliseconds for throttle. The event will be triggered this many milliseconds after the user stops scrolling.
- infiniteScrollContainer<string|HTMLElement> - (optional, default: null) - should get a html element or css selector for a scrollable element; window or current element will be used if this attribute is empty.
- scrolled<function> - this will callback if the distance threshold has been reached on a scroll down.
- scrolledUp<function> - (event: InfiniteScrollEvent) - this will callback if the distance threshold has been reached on a scroll up.
- scrollWindow<boolean> - (optional, default: true) - listens to the window scroll instead of the actual element scroll. this allows to invoke a callback function in the scope of the element while listenning to the window scroll.
- immediateCheck<boolean> - (optional, default: false) - invokes the handler immediately to check if a scroll event has been already triggred when the page has been loaded (i.e. - when you refresh a page that has been scrolled).
- infiniteScrollDisabled<boolean> - (optional, default: false) - doesn't invoke the handler if set to true
By default, the directive listens to the window scroll event and invoked the callback.
To trigger the callback when the actual element is scrolled, these settings should be configured:
- set an explict css "height" value to the element
First, import the InfiniteScrollModule to your module:
In this example, the onScroll callback will be invoked when the window is scrolled down:
in this example, whenever the "search-results" is scrolled, the callback will be invoked:
In this example, the onScrollDown callback will be invoked when the window is scrolled down and the onScrollUp callback will be invoked when the window is scrolled up: