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 hidden or 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 |
Author
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-nativefirstmyproject/index.ios.js, like this:Pagination Container / Basic Props
falsebooldotThemeLightprop (setting it totrue) the pagination dots swaps to a a light theme. By default they are dark.falsebool{}style object{}style object{}style object{}Dot Icons
Start/End Dots Only
startDotIconName(whenhorizontal)"chevron-left"icon namestartDotIconName(whenvertical)"chevron-up"icon nameendDotIconName(whenhorizontal)"chevron-right"icon nameendDotIconName(whenvertical)"chevron-down"icon namestartDotIconSize15numberendDotIconSize15numberstartDotIconFamily/endDotIconFamilyfont familyEntypo,EvilIcons,FontAwesome,Foundation,Ionicons,MaterialIcons,MaterialCommunityIcons,Octicons,Zocial,SimpleLineIcons(available in react-native-vector-icons package)Pagination Dots Only
dotIconFamily"MaterialCommunityIcons"font familyEntypo,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 name15number10number"rgba(0,0,0,.5)"color"rgba(0,0,0,.3)"color"rgba(0,0,0,.2)"colorwhen using dotThemeLight
"rgba(255,255,255,.4)"color"rgba(255,255,255,.5)"color"rgba(255,255,255,.2)"colorDot Text (Numbering Displayed)
Start/End Dots Only
11number11numberPagination Dots Only
numbernumbernumber"rgba(0,0,0,.5)"color"rgba(0,0,0,.3)"color"rgba(0,0,0,.2)"colorwhen using dotThemeLight
"rgba(255,255,255,.4)"color"rgba(255,255,255,.5)"color"rgba(255,255,255,.2)"colorAdvanced Positioning
dotSwapAxis(all pagination dots)/startDotSwapAxis/endDotSwapAxisbooldotPositionIconBeforeText(all pagination dots)/startDotPositionIconBeforeText/endDotPositionIconBeforeTextboolflexDirectiondefault style property.Wanna move anything to the left, right, top, or bottom of something? Then use
dotSwapAxisin combination until you find the right mixstartDotPositionIconBeforeText.Visibility
dotIconHide/startDotIconHide/endDotIconHidebooldotIconHide/startDotIconHide/endDotIconHidebooldotTextHide/startDotTextHide/endDotTextHidebool