jquery抽奖转盘java_jquery实现九宫格大转盘抽奖
下面我们来分享一个九宫格抽奖特效
特效说明:
一款jQuery九宫格大转盘抽奖代码网页特效,点击抽奖按钮开始随机抽奖选择奖品,可设置起点位置、奖品数量、转动次数、中奖位置参数。(兼容测试:IE7及以上、Firefox、Chrome、Opera、Safari、360等主流浏览器)
HTML:
js部分
var lottery={
index:-1,//当前转动到哪个位置,起点位置
count:0,//总共有多少个位置
timer:0,//setTimeout的ID,用clearTimeout清除
speed:20,//初始转动速度
times:0,//转动次数
cycle:50,//转动基本次数:即至少需要转动多少次再进入抽奖环节
prize:-1,//中奖位置
init:function(id){
if ($("#"+id).find(".lottery-unit").length>0) {
$lottery = $("#"+id);
$units = $lottery.find(".lottery-unit");
this.obj = $lottery;
this.count = $units.length;
$lottery.find(".lottery-unit-"+this.index).addClass("active");
};
},
roll:function(){
var index = this.index;
var count = this.count;
var lottery = this.obj;
$(lottery).find(".lottery-unit-"+index).removeClass("active");
index += 1;
if (index>count-1) {
index = 0;
};
$(lottery).find(".lottery-unit-"+index).addClass("active");
this.index=index;
return false;
},
stop:function(index){
this.prize=index;
return false;
}
};
function roll(){
lottery.times += 1;
lottery.roll();
if (lottery.times > lottery.cycle+10 && lottery.prize==lottery.index) {
clearTimeout(lottery.timer);
lottery.prize=-1;
lottery.times=0;
click=false;
}else{
if (lottery.times
lottery.speed -= 10;
}else if(lottery.times==lottery.cycle) {
var index = Math.random()*(lottery.count)|0;
lottery.prize = index;
}else{
if (lottery.times > lottery.cycle+10 && ((lottery.prize==0 && lottery.index==7) || lottery.prize==lottery.index+1)) {
lottery.speed += 110;
}else{
lottery.speed += 20;
}
}
if (lottery.speed<40) {
lottery.speed=40;
};
//console.log(lottery.times+'^^^^^^'+lottery.speed+'^^^^^^^'+lottery.prize);
lottery.timer = setTimeout(roll,lottery.speed);
}
return false;
}
var click=false;
window.οnlοad=function(){
lottery.init('lottery');
$("#lottery a").click(function(){
if (click) {
return false;
}else{
lottery.speed=100;
roll();
click=true;
return false;
}
});
};
CSS部分
/* 效果CSS开始 */
#lottery{width:574px;height:584px;margin:0px auto;background:url(../images/bg.jpg) no-repeat;padding:50px 55px;}
#lottery table td{width:142px;height:142px;text-align:center;vertical-align:middle;font-size:24px;color:#333;font-index:-999}
#lottery table td a{width:284px;height:284px;line-height:150px;display:block;text-decoration:none;}
#lottery table td.active{background-color:#ea0000;}
/* 效果CSS结束 */
JS中可设置参数:
index:-1, //当前转动到哪个位置,起点位置
count:0, //总共有多少个位置
timer:0, //setTimeout的ID,用clearTimeout清除
speed:20, //初始转动速度
times:0, //转动次数
cycle:50, //转动基本次数:即至少需要转动多少次再进入抽奖环节
prize:-1, //中奖位置
最后奉上演示图
jquery抽奖转盘java_jquery实现九宫格大转盘抽奖相关推荐
- C#保留2位小数几种场景总结 游标遍历所有数据库循环执行修改数据库的sql命令 原生js轮盘抽奖实例分析(幸运大转盘抽奖) javascript中的typeof和类型判断...
C#保留2位小数几种场景总结 场景1: C#保留2位小数,.ToString("f2")确实可以,但是如果这个数字本来就小数点后面三位比如1.253,那么转化之后就会变成1.25. ...
- Axure移动端app抽奖转盘+电商圆盘抽奖+商品抽奖+年会抽奖+抽奖动态+Axure通用抽奖转盘组件原型+九宫格方形随机抽奖原型组件+运营活动抽奖转盘
Axure移动端app抽奖转盘+电商圆盘抽奖+商品抽奖+年会抽奖+抽奖动态+Axure通用抽奖转盘组件原型+九宫格方形随机抽奖原型组件+运营活动抽奖转盘 原型演示及下载地址:https://www.p ...
- 手机抽奖页面代码html,html5大转盘抽奖支持手机转盘抽奖代码
特效描述:html5 大转盘抽奖 支持手机 转盘抽奖代码.html5转盘,html5抽奖,手机转盘,手机抽奖,手机转盘抽奖,可配置奖品抽奖. 代码结构 1. 引入CSS 2. 引入JS 3. HTML ...
- php mysql随机抽奖源码_幸运大转盘-jQuery+PHP实现的抽奖程序
目前好多网站上应用的转盘抽奖程序大多是基于flash的,而本文结合实例将使用jQuery和PHP来实现转盘抽奖程序,为了便于理解,作者分两部分来讲解,本文讲解第一部分,侧重使用jQuery实现转盘的转 ...
- php转盘中奖率,PHP大转盘中奖概率算法实例_PHP
本文实例讲述了PHP大转盘中奖概率算法的实现方法,分享给大家供大家参考.具体如下: 大转盘是最近很多线上网动中一个比较有意思的东西了,下面我们就来看看这个大转盘中奖概率算法与例子,希望对各位有所帮助. ...
- js之原生js轮盘抽奖实例分析(幸运大转盘抽奖)
效果图: 所需图片素材: 这张图是pointer.png的位置的. turntable-bg.jpg这张是转盘背景图,在背景位置. 这张是turntable.png位置的. 需要这三张图片,如果要实现 ...
- 幸运抽奖java技术文档_原生js轮盘抽奖实例分析(幸运大转盘抽奖)
效果图: 所需图片素材: 这张图是pointer.png的位置的. turntable-bg.jpg这张是转盘背景图,在背景位置. 这张是turntable.png位置的. 需要这三张图片,如果要实现 ...
- css3动大转盘,css3的animation大转盘写法
alternate 动画会在厅数次数(1,3,5等等)正常播放,面在偶数次数(2,4,4)向后播放html> Document *{ padding: 0; margin: 0; } #herh ...
- html幸运大转盘,HTML5+Fontawesome 幸运大转盘
CSS 语言: CSSSCSS 确定 * { margin: 0; padding: 0; } body { background: #eaeaea; color: #fff; font-size: ...
最新文章
- 速度、准确率与泛化性能媲美SOTA CNN,Facebook开源高效图像Transformer
- idea离线下载lombok,以及lobok版本不兼容
- Jqgried树形列表
- 【Java】使用For和递归解决不死神兔问题,求第20个月兔子的对数
- CSS 总结我对3D效果的一些误解
- 如何编写优质的API文档
- LeetCode 111 二叉树的最小深度
- Mybatis 动态传入order by 参数排序无效
- linux命令ps -aux|grep xxx详解
- 电子签章(Electronic Signature)在C#中的实现方法
- 博图注册表删除方法_arcgis 10.2安装时error1606以及error2753解决方法记录
- MySQL大略学习(二) 表格的操作 增删查改
- openfeign配置代理服务器
- [转帖]地理上的济南,是个怎样的城市?
- 学python要有多少英语词汇量_学习英语到底多少词汇量够用,1年能学习到1000的词汇量吗?...
- 【HTML505】HTML基础05_区块_布局
- 电脑重装Win10如何选择32位和64位的系统
- JDBC初学总结(四)
- python 病毒 文件复制_python病毒
- XSS————2、XSS bypass