博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
j抽奖
阅读量:6983 次
发布时间:2019-06-27

本文共 1670 字,大约阅读时间需要 5 分钟。

var lottery = { index: 0, //当前转动到哪个位置,起点位置 count: 0, //总共有多少个位置 timer: 0, //setTimeout的ID,用clearTimeout清除 speed: 150, //初始转动速度 times: 0, //转动次数 cycle: 30, //转动基本次数:即至少需要转动多少次再进入抽奖环节 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; lottery.speed = 150; clickFlg = false; lotteryCbk(); } else { if(lottery.times < lottery.cycle) { lottery.speed -= 1; } 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; }; lottery.timer = setTimeout(roll, lottery.speed); } return false;}复制代码

转载地址:http://moxpl.baihongyu.com/

你可能感兴趣的文章
细说linux挂载
查看>>
阿里资深系统架构师九峰谈云计算
查看>>
Android的多任务之路
查看>>
Autochk program not found - skipping auocheck
查看>>
☆聊聊Spring系列_Index
查看>>
我的友情链接
查看>>
不用软件,手动修复双系统引导进win7,xp的多种方法
查看>>
python 访问需要HTTP Basic Authentication认证的资源
查看>>
java中比较字符串的大小用String的compareTo()
查看>>
plist使用
查看>>
Linux RAR 安装和使用
查看>>
【OC】【一秒就会】【collectionView 头部吸住功能】
查看>>
51CTO下载 好资料分享
查看>>
linux 下转换UTC到本地时间
查看>>
Linux的起源与各发行版的基本知识
查看>>
单播包、广播包、组播包、洪泛包
查看>>
23种设计模式之解释器模式
查看>>
iptables命令结构之命令
查看>>
RabbitMQ之Exchange分类
查看>>
综合布线系统的构成
查看>>