├── .babelrc ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .prettierrc ├── LICENSE ├── README.md ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── __tests__ │ └── App-test.js ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── example-tvOS │ │ └── Info.plist │ ├── example-tvOSTests │ │ └── Info.plist │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── example-tvOS.xcscheme │ │ │ └── example.xcscheme │ ├── example.xcworkspace │ │ └── contents.xcworkspacedata │ ├── example │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m ├── metro.config.js ├── package.json ├── src │ ├── components │ │ └── CircleListItem.js │ └── mockData │ │ └── index.js └── yarn.lock ├── index.js ├── package.json ├── react-native-circle-list.gif ├── src ├── CircleList.js ├── CircleListLayout.js ├── __mocks__ │ └── mockData.js └── __tests__ │ ├── CircleList.test.js │ ├── CircleListLayout.test.js │ └── __snapshots__ │ ├── CircleList.test.js.snap │ └── CircleListLayout.test.js.snap └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["module:metro-react-native-babel-preset"] 3 | } 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | node: true, 4 | browser: true, 5 | es6: true, 6 | }, 7 | parser: 'babel-eslint', 8 | extends: [ 9 | 'airbnb', 10 | 'plugin:react/recommended', 11 | 'plugin:jest/recommended', 12 | 'plugin:prettier/recommended', 13 | ], 14 | plugins: ['react'], 15 | rules: { 16 | 'react/jsx-filename-extension': 0, 17 | 'import/prefer-default-export': 0, 18 | 'no-underscore-dangle': 0, 19 | camelcase: 0, 20 | 'no-use-before-define': 0, 21 | 'comma-dangle': 0, 22 | 'prettier/prettier': ['error', { singleQuote: true, printWidth: 100 }], 23 | 'no-unused-vars': [2, { args: 'after-used', argsIgnorePattern: '^_' }], 24 | 'react/destructuring-assignment': 0, 25 | 'react/prop-types': 0, 26 | 'react/jsx-indent': 0, 27 | 'react/jsx-indent-props': 0, 28 | 'react/display-name': 0, 29 | 'no-console': 0, 30 | 'global-require': 0, 31 | 'react/no-did-update-set-state': 0, 32 | 'no-plusplus': 0, 33 | 'consistent-return': 0, 34 | 'array-callback-return': 0, 35 | 'no-unused-expressions': 0, // See text input line 22 36 | 'react/sort-comp': [ 37 | 2, 38 | { 39 | order: ['constructor', 'static-methods', 'everything-else', 'lifecycle', 'render'], 40 | groups: { 41 | constructor: ['constructor'], 42 | lifecycle: [ 43 | 'displayName', 44 | 'propTypes', 45 | 'contextTypes', 46 | 'childContextTypes', 47 | 'mixins', 48 | 'statics', 49 | 'defaultProps', 50 | 'getDefaultProps', 51 | 'getInitialState', 52 | 'getChildContext', 53 | 'getDerivedStateFromProps', 54 | 'componentWillMount', 55 | 'UNSAFE_componentWillMount', 56 | 'componentDidAppear', 57 | 'componentDidMount', 58 | 'componentWillReceiveProps', 59 | 'UNSAFE_componentWillReceiveProps', 60 | 'shouldComponentUpdate', 61 | 'componentWillUpdate', 62 | 'UNSAFE_componentWillUpdate', 63 | 'getSnapshotBeforeUpdate', 64 | 'componentDidUpdate', 65 | 'componentDidCatch', 66 | 'componentWillUnmount', 67 | ], 68 | }, 69 | }, 70 | ], 71 | }, 72 | globals: { 73 | fetch: true, 74 | __DEV__: true, 75 | }, 76 | settings: { 77 | 'import/resolver': { 78 | node: { 79 | extensions: ['.js', '.ios.js', '.android.js'], 80 | }, 81 | }, 82 | }, 83 | } 84 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.gif 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /example 3 | */__mocks__ 4 | */__tests__ 5 | *.gif 6 | .eslintrc.js 7 | .prettierrc 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid", 3 | "bracketSpacing": true, 4 | "semi": false, 5 | "singleQuote": true, 6 | "tabWidth": 4, 7 | "trailingComma": "es5", 8 | "printWidth": 100 9 | } 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 mjinkens1 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-circle-list 2 | 3 | ### Description 4 | 5 | A React Native component implemented in Javascript to create a circular list of elements with infinite scroll. Data is mapped onto a fixed number of elements so no matter how long your list is, it will appear to render in the given circle size. 6 | 7 | ![](react-native-circle-list.gif) 8 | 9 | ### Installation 10 | 11 | ```sh 12 | $ yarn add react-native-circle-list 13 | $ npm install react-native-circle-list 14 | ``` 15 | 16 | ### Example Usage 17 | 18 | ``` 19 | ... 20 | import CircleList from 'react-native-circle-list' 21 | ... 22 | 23 | export class ExampleUsage extends PureComponent { 24 | 25 | _keyExtractor = item => item.id 26 | 27 | _renderItem = ({ item }) => 28 | 29 | render() { 30 | const { data } = this.props 31 | 32 | return ( 33 | 38 | ) 39 | } 40 | } 41 | ``` 42 | 43 | ### Props 44 | 45 | | Prop | Default | Description | Required | 46 | | -------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | 47 | | containerStyle | undefined | Override default container styling. | No | 48 | | data | [] | Array of objects, similar to React Native's FlatList. | Yes | 49 | | elementCount | 12 | Number of elements that form the circle. Any value lower than 12 will have no effect as this is the smallest amount to form a circular list. Max element count is 40, any number greater than this will have no effect. Most arc shapes can still be achieved with the proper combination of element count, radius, and flatness. | No | 50 | | flatness | 0 | Value between 0-1 specifying the flatness of the visible part of the circle. With a flatness of 1 (fully flat) only uniformly sized elements are supported currently. | No | 51 | | innerRef | undefined | Gets the ref for the CircleList component . | No | 52 | | keyExtractor | undefined | Function to extract list item keys from dataset, similar to React Native's FlatList | Yes | 53 | | onScroll | undefined | Called continuously as the list is scrolled. | No | 54 | | onScrollBegin | undefined | Called once when scrolling of the list begins. | No | 55 | | onScrollEnd | undefined | Called once when scrolling of the list ends. | No | 56 | | radius | 1.2 \* (SCREEN_WIDTH / 2) | Radius of the circle form by the list elements. | No | 57 | | renderItem | undefined | Function to that returns a React Component or elements to render, similar to React Native's FlatList. | Yes | 58 | | selectedItemScale | 1.15 | Scaling factor for the selected item. | No | 59 | | swipeSpeedMultiplier | 40 | Postive number to customize how quickly the list rotates in response to a gesture. A higher number means more movement for a given gesture. | No | 60 | | visiblityPadding | 3 | How many elements to show on either side of the selected element. | No | 61 | 62 | ### Methods 63 | 64 | | Method | Arguments | Description | 65 | | ------------- | ----------------- | -------------------------------------------------------------------------------- | 66 | | scrollToIndex | (index, duration) | Scrolls to the specified index in the given duration. Default duration is 250ms. | 67 | 68 | ### PRs Welcome! 69 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | inexact-spread=warn 60 | unnecessary-invariant=warn 61 | signature-verification-failure=warn 62 | deprecated-utility=error 63 | 64 | [strict] 65 | deprecated-type 66 | nonstrict-import 67 | sketchy-null 68 | unclear-type 69 | unsafe-getters-setters 70 | untyped-import 71 | untyped-type-import 72 | 73 | [version] 74 | ^0.113.0 75 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React, {PureComponent} from 'react'; 2 | import { 3 | Button, 4 | Dimensions, 5 | StyleSheet, 6 | Text, 7 | TextInput, 8 | View, 9 | } from 'react-native'; 10 | import Slider from '@react-native-community/slider'; 11 | import CircleList from 'react-native-circle-list'; 12 | import {CircleListItem} from './src/components/CircleListItem'; 13 | import {mockData} from './src/mockData'; 14 | 15 | const {width} = Dimensions.get('screen'); 16 | const RADIUS = (1.5 * width) / 2; 17 | 18 | export default class App extends PureComponent { 19 | state = { 20 | flatness: 0, 21 | scrolling: false, 22 | text: '0', 23 | }; 24 | 25 | _keyExtractor = item => item.id; 26 | 27 | _onChange = text => { 28 | const filteredText = text.replace(/[^0-9]/, ''); 29 | 30 | if (parseInt(filteredText, 10) > mockData.length - 1) { 31 | return; 32 | } 33 | 34 | this.setState({text: filteredText}); 35 | }; 36 | 37 | _onPress = () => { 38 | const {text} = this.state; 39 | const scrollIndex = parseInt(text, 10); 40 | 41 | this.circleList.scrollToIndex(scrollIndex); 42 | }; 43 | 44 | _onScrollBegin = () => this.setState({scrolling: true}); 45 | 46 | _onScrollEnd = () => this.setState({scrolling: false}); 47 | 48 | _onSliderChange = flatness => this.setState({flatness}); 49 | 50 | _renderItem = ({item}) => ( 51 | 52 | ); 53 | 54 | render() { 55 | const {flatness, scrolling, text} = this.state; 56 | 57 | return ( 58 | 59 | { 66 | this.circleList = component; 67 | }} 68 | onScrollBegin={this._onScrollBegin} 69 | onScrollEnd={this._onScrollEnd} 70 | renderItem={this._renderItem} 71 | /> 72 | Choose Scroll Index 73 | this._onChange(text)} 76 | style={styles.textInput} 77 | value={text} 78 | /> 79 |