forked from 94cstyles/lottery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wenchao
committed
Dec 22, 2015
0 parents
commit 1eb750b
Showing
34 changed files
with
2,300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
npm-debug.log | ||
node_modules | ||
bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(){}); | ||
``` | ||
|
||
|
||
## 浏览器支持 | ||
|
||
 |  |  |  |  | ||
--- | --- | --- | --- | --- | | ||
Latest ✔ | Latest ✔ | 10+ ✔ | Latest ✔ | Latest ✔ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.