{"id":18488482,"url":"https://github.com/f111fei/react-native-banner-carousel","last_synced_at":"2025-10-29T00:40:21.670Z","repository":{"id":41055481,"uuid":"98991448","full_name":"f111fei/react-native-banner-carousel","owner":"f111fei","description":"a carousel component for React Native","archived":false,"fork":false,"pushed_at":"2022-06-19T23:45:00.000Z","size":3342,"stargazers_count":103,"open_issues_count":17,"forks_count":47,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T01:09:28.329Z","etag":null,"topics":["carousel","react-native","react-native-carousel","react-native-swiper","react-native-viewpager","swiper"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/f111fei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-01T10:55:50.000Z","updated_at":"2024-04-17T02:42:21.000Z","dependencies_parsed_at":"2022-09-07T17:34:01.174Z","dependency_job_id":null,"html_url":"https://github.com/f111fei/react-native-banner-carousel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f111fei%2Freact-native-banner-carousel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f111fei%2Freact-native-banner-carousel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f111fei%2Freact-native-banner-carousel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f111fei%2Freact-native-banner-carousel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f111fei","download_url":"https://codeload.github.com/f111fei/react-native-banner-carousel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143524,"owners_count":21054793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carousel","react-native","react-native-carousel","react-native-swiper","react-native-viewpager","swiper"],"created_at":"2024-11-06T12:51:47.760Z","updated_at":"2025-10-29T00:40:16.639Z","avatar_url":"https://github.com/f111fei.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# react-native-banner-carousel\n\nSwiper component for React Native. Compatible with Android \u0026 iOS. Pull requests are very welcome!\n\n## Show Case\n\n![](images/showcase.gif)\n\n![](https://user-images.githubusercontent.com/7069719/28824969-0886c69e-76f7-11e7-8119-d77646246d98.png)\n\n[explore in expo](https://expo.io/@xzper/react-native-banner-carousel-example)\n\n\n## Install\n```\n$ npm install --save react-native-banner-carousel\n```\n\n## Usage\n\n```js    \nimport React from 'react';\nimport Carousel from 'react-native-banner-carousel';\nimport { StyleSheet, Image, View, Dimensions } from 'react-native';\n\nconst BannerWidth = Dimensions.get('window').width;\nconst BannerHeight = 260;\n\nconst images = [\n    \"http://xxx.com/1.png\",\n    \"http://xxx.com/2.png\",\n    \"http://xxx.com/3.png\"\n];\n\nexport default class App extends React.Component {\n    renderPage(image, index) {\n        return (\n            \u003cView key={index}\u003e\n                \u003cImage style={{ width: BannerWidth, height: BannerHeight }} source={{ uri: image }} /\u003e\n            \u003c/View\u003e\n        );\n    }\n\n    render() {\n        return (\n            \u003cView style={styles.container}\u003e\n                \u003cCarousel\n                    autoplay\n                    autoplayTimeout={5000}\n                    loop\n                    index={0}\n                    pageSize={BannerWidth}\n                \u003e\n                    {images.map((image, index) =\u003e this.renderPage(image, index))}\n                \u003c/Carousel\u003e\n            \u003c/View\u003e\n        );\n    }\n}\n\nconst styles = StyleSheet.create({\n    container: {\n        flex: 1,\n        backgroundColor: '#fff',\n        justifyContent: 'center'\n    },\n});\n```\n\n## Properties\n\n### Base\n\n| Prop  | Default  | Type | Description |\n| :------------ |:---------------:| :---------------:| :-----|\n| **pageSize** | windowWidth | `number` | the size of carousel page, must be the same for all of them. Required with horizontal carousel.  |\n| loop | true | `bool` | Set to `false` to disable continuous loop mode. |\n| index | 0 | `number` | Index number of initial slide. |\n| autoplay | true | `bool` | Set to `true` enable auto play mode. |\n| autoplayTimeout | 5000 | `number` | Delay between auto play transitions (in Millisecond). |\n| animation | - | `func` | function that returns a React Native Animated configuration. `(animate: Animated.Value, toValue: number) =\u003e Animated.CompositeAnimation;` |\n| onPageChanged | - | `func` | page change callback. `(index: number) =\u003e void;` |\n\n### Pagination\n\n| Prop  | Default  | Type | Description |\n| :------------ |:---------------:| :---------------:| :-----|\n| showsPageIndicator | true | `bool` | Set to true make pagination indicator visible.  |\n| pageIndicatorContainerStyle | - | `style` | Custom styles will merge with the default styles. |\n| pageIndicatorStyle | - | `style` | Custom styles will merge with the default styles. |\n| activePageIndicatorStyle | - | `style` | Custom styles will merge with the default styles. |\n| pageIndicatorOffset | 16 | `number` | The active page indicator offset when change page. |\n| renderPageIndicator | - | `func` | Complete control how to render pagination. `(config: PageIndicatorConfig) =\u003e JSX.Element;`. |\n\n#### PageIndicatorConfig\n```js\ninterface PageIndicatorConfig {\n    pageNum: number;\n    childrenNum: number;\n    loop: boolean;\n    scrollValue: Animated.Value;\n}\n```\n\n#### Custom Pagination Indicator\n\nHere is an example for custom pagination indicator:\n```js\nrenderIndicator(config: PageIndicatorConfig) {\n    const { childrenNum, pageNum, loop, scrollValue } = config;\n    if (pageNum === 0) {\n        return null;\n    }\n\n    const indicators: JSX.Element[] = [];\n    for (let i = 0; i \u003c pageNum; i++) {\n        indicators.push(\u003cView key={i} style={[styles.pageIndicatorStyle, this.props.pageIndicatorStyle]} /\u003e);\n    }\n\n    let left: Animated.AnimatedInterpolation;\n\n    if (pageNum === 1) {\n        left = this.state.scrollValue.interpolate({\n            inputRange: [0, 1],\n            outputRange: [0, 0]\n        });\n    } else if (!loop) {\n        left = this.state.scrollValue.interpolate({\n            inputRange: [0, 1],\n            outputRange: [0, 16]\n        });\n    } else {\n        left = this.state.scrollValue.interpolate({\n            inputRange: [0, 1, 2, childrenNum - 2, childrenNum - 1],\n            outputRange: [0, 0, 16, 16 * (childrenNum - 3), 16 * (childrenNum - 3)]\n        });\n    }\n\n    return (\n        \u003cView style={{ position: 'absolute', alignSelf: 'center', flexDirection: 'row', bottom: 10 }}\u003e\n            {indicators}\n            \u003cAnimated.View\n                style={[\n                    this.props.pageIndicatorStyle, this.props.activePageIndicatorStyle,\n                    { left: left }\n                ]}\n            /\u003e\n        \u003c/View\u003e\n    );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff111fei%2Freact-native-banner-carousel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff111fei%2Freact-native-banner-carousel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff111fei%2Freact-native-banner-carousel/lists"}