All Projects → rrd-fe → react-native-super-lottery

rrd-fe / react-native-super-lottery

Licence: other
react native prize wheel 9宫格抽奖

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to react-native-super-lottery

use-socket.io-client
https://www.npmjs.com/package/use-socket.io-client
Stars: ✭ 47 (+23.68%)
Mutual labels:  react-hooks
react-native-react-bridge
An easy way to integrate your React (or Preact) app into React Native app with WebView.
Stars: ✭ 84 (+121.05%)
Mutual labels:  react-hooks
tacklebox
🎣React UX components for handling common interactions
Stars: ✭ 15 (-60.53%)
Mutual labels:  react-hooks
useReduction
useReducer without boilerplate
Stars: ✭ 36 (-5.26%)
Mutual labels:  react-hooks
pokehooks-labs
A laboratory to use pokemons and do some experiments with React Hooks API
Stars: ✭ 35 (-7.89%)
Mutual labels:  react-hooks
react-hubspot
A collection of React hooks for interacting with Hubspot APIs
Stars: ✭ 20 (-47.37%)
Mutual labels:  react-hooks
almost-components uniapp
uni-app 使用的多端组件集合,支持APP、H5、小程序
Stars: ✭ 37 (-2.63%)
Mutual labels:  lottery
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (+363.16%)
Mutual labels:  react-hooks
hookstore
Hook based and lightweight centralized state management for React.
Stars: ✭ 28 (-26.32%)
Mutual labels:  react-hooks
react-hooks-sse
Subscribe to an SSE endpoint with React Hooks
Stars: ✭ 60 (+57.89%)
Mutual labels:  react-hooks
use-detect-print
A react hook to detect when a page is being printed
Stars: ✭ 55 (+44.74%)
Mutual labels:  react-hooks
use-monaco
Use 🗒️ monaco-editor in any ⚛️ React app with simple hooks 🎣
Stars: ✭ 85 (+123.68%)
Mutual labels:  react-hooks
use-breakpoint
React `useBreakpoint` hook to have different values for a variable based on a breakpoints.
Stars: ✭ 17 (-55.26%)
Mutual labels:  react-hooks
7-react-admin-ts
用 ts + react-hooks 实现的管理后台
Stars: ✭ 23 (-39.47%)
Mutual labels:  react-hooks
use-global-hook
Painless global state management for React using Hooks and Context API in 1KB!
Stars: ✭ 54 (+42.11%)
Mutual labels:  react-hooks
react-hook-geolocation
A React hook to access data from the Geolocation API
Stars: ✭ 31 (-18.42%)
Mutual labels:  react-hooks
ethereum-lottery
Ethereum smart contract lottery: 5 people send 0.2 ether, contract sends 0.8 ethers to one of the senders at random and 0.2 ethers to givedirectly
Stars: ✭ 22 (-42.11%)
Mutual labels:  lottery
stated-bean
A light but scalable view-model library with react hooks
Stars: ✭ 36 (-5.26%)
Mutual labels:  react-hooks
react-hook-layout
Layouts in React.
Stars: ✭ 16 (-57.89%)
Mutual labels:  react-hooks
furl
Functional react.js components.
Stars: ✭ 33 (-13.16%)
Mutual labels:  react-hooks

react-native-super-lottery

Show Case

Install

$ npm i react-native-super-lottery --save

Usage

转盘只支持九宫格。

// 引入相关的类库
import { Lottery, LotteryItem } from 'react-native-super-lottery';
// 调用Lottery组件
<Lottery
    ref={this.lotteryRef}
    data={lotteryData}
    renderItem={this.renderItem}
    defaultLucky={5}
/>
// 开始转盘抽奖
this.lotteryRef.current.start();
this.lotteryRef.current.stop(5, () => {});

Properties

Prop Default Type Description
data [] array 转盘奖品列表,奖品按照数据顺序依次在九宫格中展示,第五个奖品应该为抽奖按钮,具体可以参考Demo数据结构
defaultLucky number 默认的中奖奖品,防止出现异常或者网络请求失败,默认停留的奖品位置,比如谢谢参与
renderItem (item, index, highLightIndex) => JSX.Element function 详细参考下面

renderItem 函数

根据item、index等返回转盘中的奖品展示

Prop Default Type Description
item bool 当前需要渲染的奖品
index number 当前奖品的Index
highLightIndex number 当前应该高亮的奖品index

Method

start() : 转动转盘开始抽奖

stop(index, stopCallback) : 完成抽奖,停止转盘转动

Prop Default Type Description
index number 中奖奖品在奖品数据中的index
stopCallback (index) => void number 转盘停止之后的回调函数

LotteryItem 组件

为了更方便的实现 renderItem 函数, 组件框提供了一个简版的LotteryItem,具体参数如下:

Prop Default Type Description
url string 奖品图片的url
index number 当前奖品的Index
width number 奖品图片的宽度
height number 奖品图片的高度
type 'normal' 'highLight' 'lotteryBtn'
lotteryPress function 抽奖按钮点击回调

Example

本工程的 Demo 基于expo开发,请安装expo查看效果

$ cd example
$ npm install -g expo-cli #安装 expo cli 命令行工具
$ yarn add
$ npm start

如果没有安装expo也可以通过在线Demo查看效果

DOC

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].