libj-infinite-scroll
v1.1.0
Published
Do you want to implement infinite scroll effect when user scrolls an element or scrolls the window? <br> This is it!
Downloads
1
Readme
libj-infinite-scroll
Part of libj tools
Do you want to implement infinite scroll effect when user scrolls an element or scrolls the window? This is it!
requires jQuery
Usage (npm)
npm install libj-infinite-scroll
import { InfiniteScroll } from 'libj-infinite-scroll'
function gettingPageData() {
console.log(`loading page ${scroller.getPage()}`)
}
function pageDataReceived() {
console.log(`page ${scroller.getPage() - 1} data received`);
}
function onNextPage(page, callback) {
// show data ...
var hasMore = true; //or false for the last page
callback(hasMore)
}
/* if you pass null or undefined for the first argument, then the whole window will be watched for scroll */
/* if you pass $('#someDiv') that element scroll will be watched */
var scroller = new InfiniteScroll(null, onNextPage, gettingPageData, pageDataReceived);
scroller.start();
Test
- Run this in a separate command line to start node server
node server.js
- Run one of the following to re-create bundles
npm run dev
npm run dev:watch
- Navigate to http://localhost:3000
Build
npm run build
npm run build:watch