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

nw-prize-wheel

v1.19.4

Published

转盘抽奖组件

Downloads

15

Readme

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)

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

prizeWheel.rotateTo(prize, callback)

旋转到奖品对应位置

Kind: instance method of PrizeWheel

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

prizeWheel.stopRotate()

停止旋转,中断抽奖

Kind: instance method of PrizeWheel