1.19.4 • Published 6 years ago

nw-prize-wheel v1.19.4

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

nw-prize-wheel

转盘抽奖组件

使用

import引入

$ npm install nw-prize-wheel
//or
yarn add nw-prize-wheel

首先安装nw-prize-wheel组件,然后通过import的方式引入

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标签直接引入打包好的文件

<script src="./lib/index.js"></script>
<script type="text/javascript">
    var prizeWheel = new PrizeWheel('#J_Rotate', {
        prizeQueue: [1, 3, 4, 2]
    });
</script>

旋转到指定奖项

prizeWheel.rotateTo(1, function(){console.log("callback")})

测试demo详情见nw-prize-wheel/samples文件夹下

PrizeWheel

Kind: global class
See: 源码
Author: SherryWu

new PrizeWheel(rotateSelector, config)

ParamTypeDescription
rotateSelectorstring将要旋转的元素对应的选择器
configObject转盘的相关配置
config.prizeQueueArray.<string> | Array.<number>奖项队列: 顺时针方向,从指针初始位置右侧开始,若指针初始在一个奖项扇区内,则从该奖项开始 @required
config.inSectorboolean指针初始位置是否在扇区内:false(Default)、true
config.rotatorstring旋转元素: 'pointer'(Default) - 指针旋转、'wheel' - 转盘旋转
config.turnsnumber旋转圈数: 10(Default) - 任意正整数
config.durationnumber旋转时间: 3000(Default) - 单位毫秒

prizeWheel.rotateTo(prize, callback)

旋转到奖品对应位置

Kind: instance method of PrizeWheel

ParamTypeDescription
prizestring | number中的奖项
callbackfunction中奖动效结束后的回调方法

prizeWheel.stopRotate()

停止旋转,中断抽奖

Kind: instance method of PrizeWheel

1.19.4

6 years ago

1.11.6

6 years ago

1.9.5

6 years ago

1.9.4

6 years ago

1.9.3

6 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago