1.1.0 • Published 5 years ago

libj-infinite-scroll v1.1.0

Weekly downloads
3
License
ISC
Repository
-
Last release
5 years ago

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

Build

npm run build
npm run build:watch

Make sure to test everything in all browsers (specially IE 10/11)

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago