npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@react-native-oh-tpl/react-native-better-banner

v1.1.3-0.0.3

Published

一款用于`react native`的轮播图组件,支持无缝滚动、定时滚动、指示器显示、标题显示,可轮播图片或自定义组件。 欢迎star,[项目地址与Demo:https://github.com/tmxiong/better-banner](https://github.com/tmxiong/better-banner)

Downloads

74

Readme

react-native-better-banner

一款用于react native的轮播图组件,支持无缝滚动、定时滚动、指示器显示、标题显示,可轮播图片或自定义组件。 欢迎star,项目地址与Demo:https://github.com/tmxiong/better-banner

What's New

  • 1.1.3 修复报错问题TypeError:null is not an object(evaluating'this.scrollView.scrollTo')

Installation

npm install --save react-native-better-banner

Usage

import BetterBanner from 'react-native-better-banner'

功能列表

  • [x] 图片轮播
  • [x] 自定义组件轮播
  • [x] 定时轮播
  • [x] 同步显示轮播标题
  • [x] 无缝轮播
  • [x] 指示器定制
  • [x] 点击事件回调
  • [x] 滚动事件回调

avatar
avatar

涉及主要知识点

  • [x] 父子组件传值与回调
  • [x] ref
  • [x] setNativeProps
  • [x] onLayout

Props

props | type | default | note ---|----|---|--- bannerImages | Array | []| 用于展示轮播图片, 与bannerComponents二选一 bannerComponents | Array | []| 用于展示轮播自定义组件,与bannerImages二选一 bannerHeight | Number | 250 | banner的默认高度 bannerTitles | Array | [] | 每张图片或组件对应的标题 bannerTitleTextColor | String | #fff | 每张图片或组件对应的标题的文字颜色 bannerTitleTextSize | Number | 14 | 每张图片或组件对应的标题的文字大小 scrollInterval | Number | 2000 | 自动轮播的时间间隔,单位ms isAutoScroll | Boolean | true | 是否开启自动轮播 isSeamlessScroll | Boolean | false | 是否开启无缝滚动(iOS下正常,安卓某些机型可能出现滚动异常) adaptSeamlessScrollValue | Boolean | false | 如果开启无缝滚动在某些机型滚动异常,可针对这些机型设置truefalse, 此值实际上是设置是否显示ScrollViewscrollTo的滚动动画 indicatorWidth | Number | 10 | 指示器宽度 indicatorHeight | Number | 6 | 指示器高度 indicatorColor | String | rgba(255,255,255,0.6) | 指示器颜色 indicatorStyle | Object | {} | 指示器样式,您也可以直接使用此属性一次性设置指示器宽、高、颜色和圆角等,它会覆盖以上indicatorWidth,indicatorHeightindicatorColor属性 indicatorGap | Number | 6 | 指示器之间的间隔 activeIndicatorColor | String | #fff | 活动指示器颜色 indicatorGroupPosition | String | right | 指示器组的位置,可设置left,center,right。如果您设置了bannerTitles,则此属性只能是right indicatorGroupSideOffset | Number | 10 | 指示器组的左右边距 indicatorContainerHeight | Number | 32 | 指示器容器高度 indicatorContainerBackgroundColor | String | transparent | 指示器容器背景色 onPress() | Function | ()=>{} | 点击轮播图后的回调函数,会传回banner的index onScrollEnd() | Function | ()=>{} | 滚动完每张轮播图的回调函数,等同于ScrollViewonMomentumScrollEnd

Example01

Use Custom Components
avatar

import React from 'react';
import {
    StyleSheet,
    View,
    Text,
} from 'react-native';

import BetterBanner from 'react-native-better-banner';

const App = () => {
    return (
        <View style={styles.container}>
            <BetterBanner
                bannerComponents={[
                    <View style={{
                        width: '100%',
                        height: '100%',
                        backgroundColor: '#1997fc',
                        alignItems: 'center',
                        justifyContent: 'center'
                    }}>
                        <Text style={{fontSize: 35, color: '#fff', marginBottom: 10}}>Page 01</Text>
                        <Text style={{fontSize: 15, color: '#fff'}}>Welcome! have a good time</Text>
                    </View>,
                    <View style={{
                        width: '100%',
                        height: '100%',
                        backgroundColor: '#da578f',
                        alignItems: 'center',
                        justifyContent: 'center'
                    }}>
                        <Text style={{fontSize: 35, color: '#fff', marginBottom: 10}}>Page 02</Text>
                        <Text style={{fontSize: 15, color: '#fff'}}>Welcome! have a good time</Text>
                    </View>,
                    <View style={{
                        width: '100%',
                        height: '100%',
                        backgroundColor: '#7c3fe4',
                        alignItems: 'center',
                        justifyContent: 'center'
                    }}>
                        <Text style={{fontSize: 35, color: '#fff', marginBottom: 10}}>Page 03</Text>
                        <Text style={{fontSize: 15, color: '#fff'}}>Welcome! have a good time</Text>
                    </View>,
                ]}
                bannerTitles={["Page 01 Page 01 Page 01 Page 01 Page 01 Page 01 Page 01 ", "Page 02", "Page 03"]}
                onPress={(index) => alert('you pressed index is : ' + index)}
                indicatorContainerBackgroundColor={'rgba(0,0,0,0.3)'}
                isSeamlessScroll={true}
            />
        </View>
    );
};

const styles = StyleSheet.create({
   container: {
       flex: 1
   }

});

export default App;

Example 02

Use Images
avatar

import React from 'react';
import {
    StyleSheet,
    View,
    Text,
} from 'react-native';

import BetterBanner from 'react-native-better-banner';

const App = () => {
    return (
        <View style={styles.container}>
            <BetterBanner
                bannerImages={[
                    {uri: "http://attachments.gfan.net.cn/forum/attachments2/201402/05/211339r5eizavo2g5efuar.jpg.thumb.jpg"},
                    {uri: "http://attachments.gfan.net.cn/forum/attachments2/201402/05/211342pkd8axiibj5axizi.jpg.thumb.jpg"},
                    {uri: "http://attachments.gfan.net.cn/forum/attachments2/201402/05/2113441e4dw5zvv49jkdow.jpg.thumb.jpg"},
                    {uri: "http://attachments.gfan.net.cn/forum/attachments2/201402/05/2113472s3y3y1w62n2io6y.jpg.thumb.jpg"},
                ]}
                onPress={(index) => alert('you pressed index is : ' + index)}
                isSeamlessScroll={true}
                indicatorGroupPosition={'center'}
            />
        </View>
    );
};

const styles = StyleSheet.create({
   container: {
       flex: 1
   }

});

export default App;

欢迎star,项目地址与Demo:https://github.com/tmxiong/better-banner