Description
giant-piano is a small Javascript pagination utility. All it does is providing you the logic to render a pagination component in your app.
Features
Usage
npm install giant-piano --save
Then, in your app:
var createPagination = ; /* `itemsPerPage` and `maxPages` are normally static, so you should call `createPagination` only once.*/var paginate = ; /* Then, call `paginate` with the current page number and the total amount of items.*/console;/* { showFirst: true, showPrev: true, pages: [3, 4, 5, 6, 7], showNext: true, showLast: false, lastPage: 7 }*/ console;/* { showFirst: false, showPrev: true, pages: [1, 2, 3, 4], showNext: true, showLast: false, lastPage: 4 }*/ console;/* { showFirst: false, showPrev: false, pages: [1, 2, 3, 4, 5], showNext: true, showLast: true, lastPage: 124 }*/
Run demo locally
npm start