大转盘Demo
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>大转盘</title>
<style>
*{padding:0;margin:0}
body{
text-align:center
}
.ly-plate{
position:relative;
width:480px;
height:480px;
margin: 50px auto;
}
.rotate-bg{
width:480px;
height:480px;
background:url(wheel.png);
position:absolute;
top:0;
left:0
}
.ly-plate div.lottery-star{
width:112px;
height:142px;
position:absolute;
top:166px;
left:184px;
/*text-indent:-999em;
overflow:hidden;
background:url(rotate-static.png);
-webkit-transform:rotate(0deg);*/
outline:none
}
.ly-plate div.lottery-star #lotteryBtn{
cursor: pointer;
position: absolute;
top:0;
left:0;
*left:-107px
}
</style>
</head>
<body>
<div class="ly-plate">
<div class="rotate-bg" id="lotteryBtn"></div>
<div class="lottery-star" id="wheel"><img src="wheel_1.png" ></div>
</div>
</body>
<script src="jquery-1.7.2.min.js"></script>
<script src="jQueryRotate.2.2.js"></script>
<script src="jquery.easing.min.js"></script> <script>
$(function(){
var timeOut = function(){ //超时函数
$("#lotteryBtn").rotate({
angle:0,
duration: 10000,
animateTo: 3600, //这里是设置请求超时后返回的角度,所以应该还是回到最原始的位置,2160是因为我要让它转6圈,就是360*6得来的
callback:function(){
alert('网络超时')
}
});
};
var rotateFunc = function(awards,angle,text){ //awards:奖项,angle:奖项对应的角度
$('#lotteryBtn').stopRotate();
$("#lotteryBtn").rotate({
angle:0,
duration: 6000,
animateTo: angle+3600, //angle是图片上各奖项对应的角度,1440是我要让指针旋转4圈。所以最后的结束的角度就是这样子^^
callback:function(){
alert(text)
}
});
}; $("#wheel").rotate({
bind:
{
click: function(){
var time = [0,1];
time = time[Math.floor(Math.random()*time.length)];
alert(time);
if(time==0){
timeOut(); //网络超时
}
if(time==1){
var data = [1,2,3,0]; //返回的数组
data = data[Math.floor(Math.random()*data.length)];
alert(data);
if(data==1){
rotateFunc(1,1,'恭喜您抽中的一等奖')
}
if(data==2){
rotateFunc(2,60,'恭喜您抽中的二等奖')
}
if(data==3){
rotateFunc(3,120,'恭喜您抽中的三等奖')
}
if(data==0){
var angle = [30,90,150,210,270,330];
angle = angle[Math.floor(Math.random()*angle.length)]
rotateFunc(0,angle,'很遗憾,这次您未中奖')
}
}
}
} }); })
</script>
</html>
大转盘Demo的更多相关文章
- jQuery幸运大转盘_jQuery+PHP抽奖程序的简单实现
jQuery幸运大转盘_jQuery+PHP抽奖程序的简单实现 在线实例 查看演示 完整代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
- 纯CSS3大转盘抽奖(响应式、可配置)
源于前段时候微信小程序最初火爆公测时段,把以前用 Canvas 实现的大转盘抽奖移植成微信小程序,无奈当时小程序对 Canvas 支持不够完善,只好降低用 CSS3 实现.虽然比不上 Canvas 绘 ...
- php 大转盘抽奖
包在文件中 lottery.zip <!DOCTYPE HTML><html><head><meta charset="utf-8"> ...
- asp.net+jQueryRotate开发幸运大转盘
在线抽奖程序在很多网站上很多,抽奖形式多种多样,Flash抽奖偏多,本文将给大家介绍jQuery转盘抽奖,结合代码实例将使用jQuery和asp.net来实现转盘抽奖程序,为了便于理解,文章贴出实现源 ...
- PHP幸运大转盘源码,支持ThinkPHP
原理 先看图 可以看到1-6等奖都只有1个 ,7等奖有6个.指针默认指向上图位置,记为0°. 每个奖项对应不同的角度,圆的角度为360°,分成12块,所以每块为30°. 为了防止指针指着相邻两个将向之 ...
- 微信小程序独家秘笈之抽奖大转盘
代码地址如下:http://www.demodashi.com/demo/14209.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- Java 实现大转盘抽奖
需要用到 JAVA中的Random()函数 注意:大转盘抽奖各奖项中奖概率之和为 1.奖品列表中的概率为累加概率,需要按照添加进列表的顺序进行累加,添加顺序不做要求. 实际中使用需要考虑奖品数量限制等 ...
- iOS大转盘抽奖
功能 点击大转盘旋转后固定到某个自己可以确定的位置 结构 转盘,开始按钮,指针 技术 CADisplayLink不停重绘,CGAffineTransform旋转,简单数学公式 核心代码 1.使用CAD ...
- 利用jQueryRotate旋转插件开发大转盘抽奖
前言: 公司原来开发大转盘抽奖活动用的是flash 我发现swf文件竟然有6m大,吓尿了! 其实完全可以用js写的,但是自身前端功力有限,且时间紧迫,所以直接用旋转插件就好,兼容各方面都可以保证. 1 ...
随机推荐
- CommandBehavior.CloseConnection的使用
CommandBehavior.CloseConnection的使用 分析问题 由于流模式读取数据库的特点,在具体应用时很难确定数据库连接何时才能被关闭,因为读取的动作是连续进行的,下面是一个常见的数 ...
- AES CBC 128的实现
原由 AES已经变成目前对称加密中最流行算法之一,AES可以使用128.192.和256位密钥,并且用128位分组加密和解密数据. 项目中需要使用AES对密码信息进行加密,由嵌入式设备使用C语言进行加 ...
- Hexo学习笔记--常用命令及部署步骤
参考资料: Hexo搭建Github静态博客:http://www.cnblogs.com/zhcncn/p/4097881.htmlHexo:独立博客新玩法:http://www.aips.me/h ...
- Pick two points at random from the interior of a unit square, what is the expected distance between them?
My solution is as folllowing. This integration is hard to solve. I googled it, and found the result ...
- 使用jcifs.smb.SmbFile读取Windows上共享目录的文件
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws Servl ...
- 通过布局文件来显示ListView内容并注册 ListView事件
1:layout/vlist.xml是我们的布局文件,在这里一定要对首节点加上 android:descendantFocusability="blocksDescendants" ...
- GO的数组及切片
感觉在向PYTHON学一些数组方面的功能. package main import "fmt" func main() { ]], , , , , , , , , } ] fmt. ...
- js深入研究之克隆,属性,数组,对象,函数
代码 <script type="text/javascript"> /* 克隆原型得到对象 */ function clone(object) { function ...
- 【转】NPAPI 插件无法在 Chrome 42 版及更高版本上正常运行
原文网址:https://support.google.com/chrome/answer/6213033 NPAPI 插件无法在 Chrome 42 版及更高版本上正常运行 您可以利用插件在浏览器中 ...
- http2.0 相对于 http1.1的优势
1.http2.0完全是多路复用的,只需一个连接就可实现并行 可以将不同的请求夹杂在一起,只需一个连接就能加载一个页面. 2.可以让服务器将响应主动推动到客户端缓存中 当浏览器请求一个网页时,服务器除 ...