# nw-prize-wheel

> 转盘抽奖组件

Latest version **1.19.4** (published 2018-07-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install nw-prize-wheel
pnpm add nw-prize-wheel
yarn add nw-prize-wheel
bun add nw-prize-wheel
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.19.4 |
| Published | 2018-07-25 |
| First published | 2017-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 250.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sherrywu |

## Links

- npm: https://www.npmjs.com/package/nw-prize-wheel
- npm.io page: https://npm.io/package/nw-prize-wheel

## Dependencies (3)

- [object-assign](https://npm.io/package/object-assign.md) ^4.1.1
- [nw-prize-wheel](https://npm.io/package/nw-prize-wheel.md) ^1.19.4
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.0.0-beta.32

## Recent versions

- 1.19.4 (latest) — 2018-07-25
- 1.11.6 — 2017-12-06
- 1.9.5 — 2017-11-17
- 1.9.4 — 2017-11-17
- 1.9.3 — 2017-11-16
- 1.7.0 — 2017-11-10
- 1.6.0 — 2017-11-09
- 1.5.0 — 2017-11-09
- 1.4.4 — 2017-11-09
- 1.4.3 — 2017-11-08

## README

## nw-prize-wheel
转盘抽奖组件

### 使用
#### import引入
```bash
$ npm install nw-prize-wheel
//or
yarn add nw-prize-wheel
```
首先安装nw-prize-wheel组件，然后通过import的方式引入
```javascript
import PrizeWheel from 'nw-prize-wheel';

var prizeWheel = new PrizeWheel('#J_Rotate', {
    prizeQueue: [1, 3, 4, 2]
});
```

#### script标签嵌入
下载nw-prize-wheel/lib/index.js，通过script标签直接引入打包好的文件
```html
<script src="./lib/index.js"></script>
<script type="text/javascript">
    var prizeWheel = new PrizeWheel('#J_Rotate', {
        prizeQueue: [1, 3, 4, 2]
    });
</script>
```

### 旋转到指定奖项
```javascript
prizeWheel.rotateTo(1, function(){console.log("callback")})
```
测试demo详情见nw-prize-wheel/samples文件夹下

<a name="PrizeWheel"></a>

## PrizeWheel
<p>PrizeWheel是一个转盘抽奖组件，详细接口如下所示</p>

**Kind**: global class  
**See**: <a href="https://g.hz.netease.com/winman-f2e/common-modules/tree/master/packages/nw-prize-wheel">源码</a>  
**Author**: SherryWu  

* [PrizeWheel](#PrizeWheel)
    * [new PrizeWheel(rotateSelector, config)](#new_PrizeWheel_new)
    * [.rotateTo(prize, callback)](#PrizeWheel+rotateTo)
    * [.stopRotate()](#PrizeWheel+stopRotate)

<a name="new_PrizeWheel_new"></a>

### new PrizeWheel(rotateSelector, config)

| Param | Type | Description |
| --- | --- | --- |
| rotateSelector | <code>string</code> | 将要旋转的元素对应的选择器 |
| config | <code>Object</code> | 转盘的相关配置<br> |
| config.prizeQueue | <code>Array.&lt;string&gt;</code> \| <code>Array.&lt;number&gt;</code> | 奖项队列: 顺时针方向，从指针初始位置右侧开始，若指针初始在一个奖项扇区内，则从该奖项开始 @required<br> |
| config.inSector | <code>boolean</code> | 指针初始位置是否在扇区内：false(Default)、true<br> |
| config.rotator | <code>string</code> | 旋转元素: 'pointer'(Default) - 指针旋转、'wheel' - 转盘旋转<br> |
| config.turns | <code>number</code> | 旋转圈数: 10(Default) - 任意正整数<br> |
| config.duration | <code>number</code> | 旋转时间: 3000(Default) - 单位毫秒 |

<a name="PrizeWheel+rotateTo"></a>

### prizeWheel.rotateTo(prize, callback)
旋转到奖品对应位置

**Kind**: instance method of [<code>PrizeWheel</code>](#PrizeWheel)  

| Param | Type | Description |
| --- | --- | --- |
| prize | <code>string</code> \| <code>number</code> | 中的奖项 |
| callback | <code>function</code> | 中奖动效结束后的回调方法 |

<a name="PrizeWheel+stopRotate"></a>

### prizeWheel.stopRotate()
停止旋转，中断抽奖

**Kind**: instance method of [<code>PrizeWheel</code>](#PrizeWheel)

---
_Source: https://npm.io/package/nw-prize-wheel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
