In keeping with the idea that data should represent your layout, this simple library will help you calculate your pagination navigation view.
Usage
or
<script src="https://unpkg.com/pagination-layout@1.0.5/pagination-layout.js"></script>
<script src="https://unpkg.com/pagination-layout@1.0.5/pagination-layout.min.js"></script>
const pages = [ [], [], [], [], [] ];
paginationLayout(pages);
const pages = [ [], [], [], [], [], [], [], [] ];
const currentPage = 4;
paginationLayout(pages, currentPage);
Or if you are using the -be
version:
const totalItems = 500
const itemsPerPage = 100
paginationLayout(totalItems, itemsPerPage);
const totalItems = 800;
const itemsPerPage = 100;
const currentPage = 4;
paginationLayout(totalItems, itemsPerPage, currentPage);
Build
uglifyjs pagination-layout.js > pagination-layout.min.js
uglifyjs pagination-layout-be.js > pagination-layout-be.min.js
Publish
npm publish