Skip to content

Commit

Permalink
重新整理发布
Browse files Browse the repository at this point in the history
  • Loading branch information
wenchao committed Dec 22, 2015
0 parents commit 1eb750b
Show file tree
Hide file tree
Showing 34 changed files with 2,300 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
npm-debug.log
node_modules
bower_components
133 changes: 133 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# lottery [刮刮卡,大转盘,老虎机]

## 文档说明

lottery都继承了**Events**类 插件操作传递数据都通过on绑定 都包含了3个事件[start,end,reset]</br>
start => (next) 抽奖前触发,主要用于抽奖信息处理,传递回调函数next,需进行调用。</br>
end => () 抽奖结束触发</br>
reset => () 抽奖重置触发,主要出现调用了lottery.reset()</br>

lottery都包含了3个操作函数 [setResult,reset,draw]</br>
setResult => (result) 设置抽奖结果</br>
reset => () 重置抽奖</br>
draw => () 开始抽奖(注:刮刮卡调用此方法后会直接显示结果)</br>

### 刮刮卡

```html
<canvas id="js_lottery"></canvas>
<button onclick="lottery.reset()">再来一次</button>
```

```javascript
var lottery = new Lottery.Scratch(document.getElementById('js_lottery'),{
size: 20, //滑动区域大小
percent: 50, //激活百分比到谋个值 就全显示
variable: true //canvas的大小是否是可变的
});
lottery.on('start',function(next){
next();
//中奖结果,传递是中奖结果图片地址
lottery.setResult('...imageSrc');
}).on('end',function(){}).on('reset',function(){});
```

### 大转盘

```html
<div class="dial">
<div id="js_pointer" class="pointer">
<a class="btn" href="javascript:;" onclick="lottery.draw()"></a>
</div>
</div>
```

```javascript
var lottery = new Lottery.Dial(document.getElementById('js_pointer'), {
speed: 30, //每帧速度
areaNumber: 8 //奖区数量
});
var index = -1;
lottery.on('start', function (next) {
next();
//请求获取中奖结果
index = Math.round(Math.random() * 7);
//中奖结果,传递停留奖区下标0开始
lottery.setResult(index);
}).on('end', function () {
console.log('中奖奖区:' + index);
}).on('reset',function(){});
```

### 老虎机

```html
<div class="tiger">
<div class="m-ui-tiger">
<div class="item">
<ul class="roller">
<li>
<img src="images/tiger_awards_1.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_2.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_3.png" alt=""/>
</li>
</ul>
</div>
<div class="item">
<ul class="roller">
<li>
<img src="images/tiger_awards_1.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_2.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_3.png" alt=""/>
</li>
</ul>
</div>
<div class="item">
<ul class="roller">
<li>
<img src="images/tiger_awards_1.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_2.png" alt=""/>
</li>
<li>
<img src="images/tiger_awards_3.png" alt=""/>
</li>
</ul>
</div>
<a id="js_toggle" class="toggle" href="javascript:;" onclick="lottery.draw()"></a>
</div>
</div>
```

```javascript
//老虎机动画因为性能问题采用css3 所以需要完成2个动画fx-bounce fx-roll 详细查看examples
var lottery = new Tiger(document.getElementById('js_toggle'), document.querySelectorAll('.roller'), {
timeout: 300, //每个roller间动画间隔
timeDiff: 6000, //动画执行最少时间
variable: true //roller大小是否是可变的
});
lottery.on('start', function (next) {
next();
setTimeout(function () {
var ret = [Math.round(Math.random() * 2), Math.round(Math.random() * 2), Math.round(Math.random() * 2)];
//中奖结果,传递每个roller停留下标0开始
lottery.setResult(ret);
}, 1000);
}).on('end', function(){}).on('reset',function(){});
```


## 浏览器支持

![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png)
--- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | 10+ ✔ | Latest ✔ | Latest ✔ |
23 changes: 23 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "lottery",
"homepage": "https://github.com/TOP-Chao/lottery",
"authors": [
"wenchao <[email protected]>"
],
"description": "",
"main": "gulpfile.js",
"moduleType": [],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"examples"
],
"devDependencies": {
"angular": "~1.4.7",
"top-webapp": "0.0.1"
}
}
11 changes: 11 additions & 0 deletions dist/ui-lottery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function () {
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
define(function () {
return Lottery;
});
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = Lottery;
} else {
window.Lottery = Lottery;
}
})();
1 change: 1 addition & 0 deletions dist/ui-lottery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added examples/images/dial_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/dial_page_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/dial_pointer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/scratch_ceiling.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/scratch_no.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/scratch_page_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/tiger_awards_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/tiger_awards_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/tiger_awards_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/tiger_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/tiger_page_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1eb750b

Please sign in to comment.