@thisnamespace/scrollobserver
v0.0.9
Published
Turn any container into an infinite scroll container or fire a function when reaching a particular part of a web page.
Downloads
10
Maintainers
Readme
Scroll Observer
Turn any container into an infinite scroll container or fire a function when reaching a particular part of a web page.
This simple react component allows you convert any container into infinite scroll container by firing your callback function when it appears on screen, this same concept can be used to fire the same callback function when a it appears on screen without being an infinite scroll container.
Installation
npm install @thisnamespace/scrollobserver --save
Usage example
For example you have a list of 100's of rows but you only want to load 15 at a time, create you list with your rows and the 'ScrollObserver' after it when the 'ScrollObserver' appears on screen the callback function will fire. When all the items have been fetched set 'loadMore' to false and the callback will no longer fire when the observer appears on screen.
<div>
<ul>
<li></li>
...
</ul>
<ScrollObserver callback={()=>{fetch more rows}} loadMore={true} />
</div>
Release History
- 0.1.0
- The first proper release
- 0.0.1
- Work in progress, initial commit
Meta
Michael Day – @thisnamespace – [email protected]
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/thisnamesapce
Contributing
- Fork it (https://github.com/thisnamesapce/scrollobserver/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request