ngx-infinite-scroller
Infinite and bidirectional scroll directive for Angular 11
All notable changes to this project are documented in CHANGELOG.md file.
Installation
Run npm install ngx-infinite-scroller --save
to install the library.
Usage
*.module.ts configuration
Include NgxInfiniteScrollerModule
in your module
;
*.component.html configuration
Include ngxInfiniteScroller
directive in your *.component.html
file
{{item.title}}
By default the directive works as an infinite scroll from the top to the bottom of your list. To switch to other modes, use input parameters like:
strategy="scrollingToTop"
strategy="scrollingToBottom"
(default)
strategy="scrollingToBoth"
Default value of initial scroll position depends on the strategy value:
strategy="scrollingToTop"
-> initialScrollPosition="BOTTOM"
strategy="scrollingToBoth"
-> initialScrollPosition="MIDDLE"
strategy="scrollingToBottom"
-> initialScrollPosition="TOP"
It is also possible to customize the default behaviour using an optional input field:
initialScrollPosition="TOP"
initialScrollPosition="MIDDLE"
initialScrollPosition="BOTTOM"
initialScrollPosition="50"
(position in px)
*.component.ts configuration
Handle onScrollUp
and onScrollDown
actions in your *.component.ts
file
;; ;;
*.component.scss configuration
Add some styling in your *.component.scss
file
#scroller .news
Development environment
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run npm run packagr
to build the library. The build artifacts will be stored in the dist
directory.
Publishing
Run cd dist && npm publish
command to publish the package.