0.1.2 • Published 7 years ago

js-pagination v0.1.2

Weekly downloads
15
License
-
Repository
github
Last release
7 years ago

js-pagination

pagination implemented in pure JavaScript

Install & run example

// install
npm i -S 'js-pagination'

// run example
git clone https://github.com/rainjay/pagination.git
cd pagination
npm install
npm run dev

Example demo

DEMO

Usage

require('js-pagination/dist/styles.css')
var Pagination = require('js-pagination')

// config
Pagination.config({
  ulClass: 'pagination',
  activeClass: 'active',
  ...
})

// use
var myPager = new Pagination(100, 15, function(page) {}, '.field')

myPager.getCurrentPage()
myPager.goToPage(num)

// html
<div class="field"></div>

API

config attributes (optional)

keyTypeDetails
ulClassStringclass name for page lists, default 'pagination'
activeClassStringclass name for active page item, default 'active'
disableClassStringdisable class name for disabled item, default 'disabled'
dotsStringdefault '...'
hideIfEmptyBooleanwhether to hide paging if only have one page, default true
showPreNextBolleanwhether show pre and next button, default true
scrollTopBolleanwhether scroll to top after you select one page, default false
scrollContainerStringwhich container to scroll
adjacentNumberthe page amount before and after the current page, default 2
lang'cn' or 'en'default 'cn'

var pager = new Pagination(total, size, callback, fieldSelector)

keyTypeDetails
totalNumberthe total size of what you are displaying
sizeNumbersize of each page, default 1
sizeNumbersize of each page, default 1
callbackFunctioncall back for page select operation
fieldSelectorStringthe field u want to mount, exp: '.field'

pager.goToPage(num)

keyTypeDetails
numNumberthe page num will go to

pager.getCurrentPage()