Last active
July 29, 2017 15:21
-
-
Save garrettmac/4a841bc5bf4c872f252ebdf90291b30c to your computer and use it in GitHub Desktop.
paginatiion-math.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page = Math.abs(parseInt(page) || 1) | |
console.log(" page: ",page); | |
//results to return | |
pageSize = parseInt(pageSize) || 10 | |
//cannot go above 50 | |
if(pageSize > maxsize)pageSize=maxsize | |
// limits payload size | |
let total= (µœ.data.length) | |
// let lastPage= Math.ceil((µœ.data.length)/pageSize) | |
// let lastPage= (pageSize*page)-total | |
let lastPage= Math.ceil(total/pageSize) | |
let start = (page - 1) * pageSize + 1 | |
let end = total | |
if (pageSize < total) { | |
end = pageSize * page | |
if (end > total) { | |
end = total; | |
} | |
} | |
let data=_.slice(µœ.data,start-1,end) | |
// e.g. "21-30 of 193 items" | |
console.log(start + '-' + end + ' of ' + total + ' items') | |
// filter if nessisary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The best Pagination component for React Native.
react-native-pagination
Roadmap
Show Cases
ReactNativePaginationExample/Pages/FlatListHorizontalExample.js
Getting Started
Installation
Basic Usage
react-native
firstmyproject/index.ios.js
, like this:Pagination Container / Basic Props
false
bool
dotThemeLight
prop (setting it totrue
) the pagination dots swaps to a a light theme. By default they are dark.false
bool
{}
style object
{}
style object
{}
style object
{}
Dot Icons
Start/End Dots Only
startDotIconName
(whenhorizontal
)"chevron-left"
icon name
startDotIconName
(whenvertical
)"chevron-up"
icon name
endDotIconName
(whenhorizontal
)"chevron-right"
icon name
endDotIconName
(whenvertical
)"chevron-down"
icon name
startDotIconSize
15
number
endDotIconSize
15
number
startDotIconFamily
/endDotIconFamily
font family
Entypo
,EvilIcons
,FontAwesome
,Foundation
,Ionicons
,MaterialIcons
,MaterialCommunityIcons
,Octicons
,Zocial
,SimpleLineIcons
(available in react-native-vector-icons package)Pagination Dots Only
dotIconFamily
"MaterialCommunityIcons"
font family
Entypo
,EvilIcons
,FontAwesome
,Foundation
,Ionicons
,MaterialIcons
,MaterialCommunityIcons
,Octicons
,Zocial
,SimpleLineIcons
(available in react-native-vector-icons package)"close"
icon name
"checkbox-blank-circle"
icon name
"checkbox-blank-circle-outline"
icon name
15
number
10
number
"rgba(0,0,0,.5)"
color
"rgba(0,0,0,.3)"
color
"rgba(0,0,0,.2)"
color
when using dotThemeLight
"rgba(255,255,255,.4)"
color
"rgba(255,255,255,.5)"
color
"rgba(255,255,255,.2)"
color
Dot Text (Numbering Displayed)
Start/End Dots Only
11
number
11
number
Pagination Dots Only
number
number
number
"rgba(0,0,0,.5)"
color
"rgba(0,0,0,.3)"
color
"rgba(0,0,0,.2)"
color
when using dotThemeLight
"rgba(255,255,255,.4)"
color
"rgba(255,255,255,.5)"
color
"rgba(255,255,255,.2)"
color
Advanced Positioning
dotSwapAxis
(all pagination dots)/startDotSwapAxis
/endDotSwapAxis
bool
dotPositionIconBeforeText
(all pagination dots)/startDotPositionIconBeforeText
/endDotPositionIconBeforeText
bool
flexDirection
default style property.Wanna move anything to the left, right, top, or bottom of something? Then use
dotSwapAxis
in combination until you find the right mixstartDotPositionIconBeforeText
.Visibility
dotIconHide
/startDotIconHide
/endDotIconHide
bool
dotIconHide
/startDotIconHide
/endDotIconHide
bool
dotTextHide
/startDotTextHide
/endDotTextHide
bool