0.1.2 • Published 6 years ago
infinity-scroll v0.1.2
infinity-scroll
infinity-scroll is a JavaScript library that allows you to use infinity scrolling on your website.
Installation
Using npm and webpack
npm install --save infinity-scroll
import InfinityScroll from 'infinity-scroll';
Using jsDelivr
- Before your closing
</body>
tag add:
<script src="//cdn.jsdelivr.net/npm/infinity-scroll@0.1.2/dist/infinity-scroll.min.js"></script>
Manual installation
- Download the latest version from the GitHub releases page and extract it somewhere in your project directory.
- Then, before your closing
</body>
tag add:
<script src="infinity-scroll/dist/infinity-scroll.js"></script>
Notice for Internet Explorer users
Additionally you need babel-polyfill
and whatwg-fetch
installed.
Usage
var infinityScroll = new InfinityScroll({
selector: '.posts',
url: page => `/posts/${page}`
// ...
});
Options
Option | Type | Default | Description |
---|---|---|---|
selector | string | .infinity-scroll | The selector for the container, containing the infinity scrolling items |
threshold | number | 200 | If the pixels to the page bottom are less than this, the load of the next page will be triggered |
url | function | - | A function which takes the current page number and returns the page's url as string |
onUpdate | function | - | Function which is called, after a page was loaded |
Versioning
This project uses SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.