新年网页抽奖程序

* {margin:0; padding:0;}

ul,li {list-style-type:none;}

body {overflow:hidden;}

#back {width:100%; height:100%;

background:#f5f5f5; position:absolute; z-index:1;

}

#box {width:360px; height:100px;

position:absolute; z-index:3; top:50%; left:50%;

margin-top:-50px; margin-left:-180px; text-align:center;

}

#box1,#box2,#box3 {width:100px; height:100px;

line-height:100px;

float:left; background:#321c24;

border:10px #321c24 solid;

border-radius:50%; position:relative; overflow:hidden;

}

#box1 ul,#box2 ul,#box3 ul {color:#fff; font-size:68px;

font-family:"Arial Black"; text-align:center;

width:100px; height:100px; line-height:100px;

position:absolute; top:0; left:0;

}

#box1 ul li,#box2 ul li,#box3 ul li {

width:100px; height:100px;

background:red; border-radius:50%;

}

var AIR = {

$: function (id)

{

return typeof id === "string" ? document.getElementById(id) : id;

},

$$: function (elem, oParent)

{

return (oParent || document).getElementsByTagName(elem);

},

addEvent: function (oElement, sEvent, fnHandler)

{

oElement.addEventListener ? oElement.addEventListener(sEvent, fnHandler, false) : oElement.attachEvent("on" + sEvent, fnHandler)

},

removeEvent: function (oElement, sEvent, fnHandler)

{

oElement.removeEventListener ? oElement.removeEventListener(sEvent, fnHandler, false) : oElement.detachEvent("on" + sEvent, fnHandler)

},

getElementClient: function (){

var arr = [];

if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){

arr.push(document.documentElement.clientWidth);

arr.push(document.documentElement.clientHeight);

return arr;

}

},

getStyle: function (obj, attr)

{

return parseFloat(obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr])

},

startMove: function (obj, pos, onEnd)

{

clearInterval(obj.timer);

var _this = this;

obj.timer = setInterval(function ()

{

_this.doMove(obj, pos, onEnd)

}, 30)

},

doMove: function (obj, pos, onEnd)

{

var iCurL = this.getStyle(obj, "left");

var iCurT = this.getStyle(obj, "top");

var iSpeedL = (pos.left - iCurL) / 5;

var iSpeedT = (pos.top - iCurT) / 5;

iSpeedL = iSpeedL > 0 ? Math.ceil(iSpeedL) : Math.floor(iSpeedL);

iSpeedT = iSpeedT > 0 ? Math.ceil(iSpeedT) : Math.floor(iSpeedT);

if (pos.left == iCurL && pos.top == iCurT)

{

clearInterval(obj.timer);

onEnd && onEnd()

}

else

{

obj.style.left = iCurL + iSpeedL + "px";

obj.style.top = iCurT + iSpeedT + "px";

}

}

}

function Draw (obj, num)

{

this.obj = obj;

this.num = num;

this.data = [];

this.result = [];

this.show = 0;

this.btn = true;

this.timer = true;

this.h = 0;

this.uh = 0;

this.initialize();

}

Draw.prototype = {

initialize: function ()

{

this.createArr ();

this.createElement ();

this.closeEvent ();

this.startDraw ();

},

createElement: function ()

{

for(var j=0; j

var ul = document.createElement("ul");

for(var i=0; i<10; i++){

var li = document.createElement("li");

li.innerHTML = i;

ul.appendChild(li)

}

this.obj[j].appendChild(ul);

this.obj[j].btn = true;

AIR.$$("ul",this.obj[j])[0].innerHTML += AIR.$$("ul",this.obj[j])[0].innerHTML;

}

var UL = AIR.$$("ul",this.obj[0])[0];

this.h = AIR.getStyle(AIR.$$("li",UL)[0],"height");

this.uh = AIR.$$("li",UL).length * this.h

},

randomSort: function (a, b) {

return Math.random()>.5 ? -1 : 1;

},

createArr: function ()

{

for(var i=0; i

this.data.push(i);

}

this.data.sort(this.randomSort);

},

closeEvent: function ()

{

document.οnmοusedοwn=document.οnmοusemοve=document.οncοntextmenu=function()

{

return false;

}

},

startDraw: function ()

{

var _this = this;

document.onkeyup = function ( ev )

{

var ev = ev || window.event;

if(ev.keyCode == 13 || ev.keyCode == 32){

if(_this.btn && _this.timer){

if(_this.obj[_this.obj.length-1].btn){

_this.Play ();

_this.btn = !_this.btn;

_this.timer = !_this.timer;

}

}else{

if(_this.obj[_this.obj.length-1].btn){

_this.Stop ();

_this.btn = !_this.btn;

_this.timer = !_this.timer;

}

}

return false;

}else{

return false;

}

}

},

Play: function ()

{

if(this.timer && this.btn){

var t = 0;

for(var i=0; i

this.obj[i].btn = false;

this.playTimer (this.obj[i],t);

t += 1500;

}

}else{

return false;

}

},

playTimer: function (obj,t)

{

var _this = this;

setTimeout(function(){

_this.Move (obj);

},t)

},

Del: function (a)

{

for(var i=0; i

if(a == this.data[i]){

this.data.splice(i,1);

}

}

},

Stop: function ()

{

if(!this.timer && !this.btn){

var n = this.num + 1;

var r = this.data[Math.floor(Math.random() * (0-n) + n)];

this.show = r;

this.Del (r);

r = r.toString().split("");

var c = this.obj.length - r.length;

if(r.length < this.obj.length){

for(var i=0; i

r.unshift(0)

}

}

this.result = r;

//document.title = r+" : "+this.data;

var t = 0;

for(var i=0; i

this.obj[i].btn = false;

this.obj[i].index = i;

this.obj[i].num = this.result[this.obj[i].index];

this.stopTimer (this.obj[i],t);

t += 1500;

}

}

},

stopTimer: function (obj,t)

{

var _this = this;

setTimeout(function(){

_this.showResult (obj);

},t)

},

showResult: function (obj)

{

var _this = this;

this.timer = true;

this.btn = true;

obj.btn = false;

obj.vh = -obj.num * this.h;

obj.timeOut = setInterval(function(){

obj.speed -= 1;

if(obj.speed == 1){

clearInterval(obj.timeOut);

clearInterval(obj.timer);

obj.timer = setInterval(function(){

if(obj.ul.offsetTop >= obj.vh){

clearInterval(obj.timer);

AIR.startMove(obj.ul,{left:0,top:obj.vh},function(){

obj.btn = true;

var set = true;

for(var i=0; i<_this.obj.length i>

if(!_this.obj[i].btn){

set = false;

}

}

if(set){

_this.Open(_this.show)

}

});

}

obj.ul.style.top = obj.ul.offsetTop + obj.speed +"px";

},30);

}

},100);

},

Open: function (num)

{

document.title += " "+ num;

},

Move: function (obj)

{

var _this = this;

var obj = obj;

obj.btn = false;

obj.timer = null;

obj.speed = 1;

obj.ul = AIR.$$("ul",obj)[0];

obj.ul.style.height = this.uh +"px";

obj.timer = setInterval(function(){

if(obj.ul.offsetTop > 0){

obj.ul.style.top = -(_this.uh/2) +"px";

}

obj.ul.style.top = obj.ul.offsetTop + obj.speed +"px";

},30);

obj.timeOut = setInterval(function(){

obj.speed += 1;

if(obj.speed == 30){

clearInterval(obj.timeOut);

obj.btn = true;

}

},300)

}

}

var initialize = function ()

{

new Draw ([AIR.$("box1"),AIR.$("box2"),AIR.$("box3")],100);

reSize ();

}

var reSize = function ()

{

var v = AIR.getElementClient();

AIR.$$("img",AIR.$("back"))[0].width = v[0];

AIR.$$("img",AIR.$("back"))[0].height = v[1];

}

AIR.addEvent(window,"load",initialize);

AIR.addEvent(window,"resize",reSize);

100

php抽奖的数字滚动器,JS数字抽奖游戏实现方法相关推荐

  1. php抽奖的数字滚动器,jQuery数字滚动插件

    [温馨提示]源码包解压密码:www.youhutong.com 效果图: 描述说明: jQuery数字滚动效果,可调整不同位数 使用方法 导入index.js html js调用$("#da ...

  2. 数字滚动原生js的三种方式

    数字滚动原生js的三种方式 让数字滚动的效果简单用计时器setInterval就能轻易的实现,例如 <!DOCTYPE html> <html><head>< ...

  3. html页面数字滚动,Vue.js大屏可视化数据数字滚动翻转跳转效果(通俗易懂附完整代码)...

    原文:Vue.js大屏可视化数据数字滚动翻转跳转效果(通俗易懂附完整代码) 大屏数字滚动翻转效果来源于最近工作中element后台管理页面一张大屏的UI图,该UI图上有一个模块需要有数字往上翻动的效果 ...

  4. html数字滚动选择,js实现数字滚动特效

    本文实例为大家分享了js实现数字滚动展示的具体代码,供大家参考,具体内容如下 效果图 html代码 Title #t,#tt{ border: #ccc thin solid; width: 250p ...

  5. html数字自动滚动代码怎么写,你可能需要这样的大屏数字滚动效果

    大屏数字滚动效果来源于最近工作中一张大屏的UI图,该UI图上有一个模块需要有数字往上翻动的效果,以下是最终实现的效果: 思路 在实现此效果之前,我们先来捋一下思路,用思维导图来设计一下我们的实现步骤, ...

  6. cocos2D捕鱼达人源代码初学者详解4数字滚动

    数字滚动由两个类实现,数字类UINumber和数字滚动类UIRollNum,都是继承的CCSprite,都是精灵.数字类实现单个数字的上下滚动,数字滚动类实现了界面分数数字的位置设置,分数变化时把分数 ...

  7. layui 数字步进器_9例UI设计规范模板

    设计规范对整个项目的规范性推动很强大,但是需要花时间和耐心细心打磨,所以需要花费很多时间和精力去整理资料.编辑素材.分类整合,最后还要在设计软件中将整个规范重新排列设计. 作为UI设计师,整理设计规范 ...

  8. JS 自定义实现数字滚动处理

    一.浏览器端js自定义实现数字滚动 使用示例: <!DOCTYPE html> <html lang="en"><head><meta c ...

  9. Android RecyclerView实现类似于老虎机抽奖,数字滚动等动画效果

    1.RecyclerViewLoopScrollAnimation项目介绍 RecyclerViewLoopScrollAnimation 适用于Android RecyclerView的循环滚动动画 ...

  10. 数字滚动插件——CountUp.js

    CountUp.js数字滚动插件使用方法详解 CountUp.js 是一个轻量级,无依赖的JavaScript类,通过简单的设置就可以达到数字滚动的效果 演示地址: http://inorganik. ...

最新文章

  1. Debussy的安装
  2. CSS 样式书写规范
  3. javascript 正则表达式详解
  4. 【响应式Web前端设计】css如何设置边框的圆角样式?border-radius属性设置圆角样式(图 文)
  5. NSMutableArray 排序
  6. RabbitMQ系列教程之一:我们从最简单的事情开始!Hello World
  7. 十个好习惯帮你理财省大钱
  8. matlab中fval函数,请问matlab中[x,fval,exitflag,output] = simulannealbnd(fun,...)函数怎么调用...
  9. c++ release和debug语句分离
  10. Linux之date命令
  11. 综合应用WPF/WCF/WF/LINQ之二十七:代码生成器之DBMLToProcedure
  12. Envious Exponents
  13. Ubuntu20.04 安装向日葵SunloginClient并解决报错缺少依赖问题
  14. 2020.11.16-使用Arduino测速
  15. ZEMAX | 如何倾斜和偏心序列光学元件
  16. 关于Android studio在ubuntu中真机测试运行出现Gradle build daemon disappeared unexpectedly的一个原因及解决办法
  17. 论文相关-MATHTYPE字体对应
  18. html标签中写onclick,HTML a 标签添加 onclick()事件的几种方式
  19. Linux下Bluetooth编程
  20. python证件照_python opencv实现证件照换底的方法

热门文章

  1. 四阶行列式如何降阶_四阶行列式的计算方法
  2. 安卓手机root是什么意思
  3. 安卓手机root流程
  4. 【MMDetection3D】基于单目(Monocular)的3D目标检测入门实战
  5. shell蚂蚁森林_和“蚂蚁森林”的融合
  6. sed替换字符串(变量)
  7. startup.bat闪退解决
  8. vsphere 6.5 HA 提示:此主机当前没有管理网络冗余,该主机的vSphere HA检测信号数据存储数目为0 告警消除
  9. 惠普打印机WiFi连接使用
  10. 2021-08-24