jQuery抽奖插件 jQueryRotate
实现代码
网页中引用
<
script
type
=
"text/javascript"
src
=
"js/jquery.min.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"js/jQueryRotate.2.2.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.easing.min.js"
></
script
>
<
div
class
=
"ly-plate"
>
<
div
class
=
"rotate-bg"
></
div
>
<
div
class
=
"lottery-star"
><
img
src
=
"rotate-static.png"
id
=
"lotteryBtn"
></
div
>
</
div
>
<style type=
"text/css"
>
*{
padding
:
0
;
margin
:
0
}
body{
text-align
:
center
;
background-color
:
#1664ad
;
}
.ly-plate{
position
:
relative
;
width
:
509px
;
height
:
509px
;
margin
:
50px
auto
;
}
.rotate-bg{
width
:
509px
;
height
:
509px
;
background
:
url
(ly-plate.png);
position
:
absolute
;
top
:
0
;
left
:
0
;
margin-top
:
0%
;
}
.ly-plate div.lottery-star{
width
:
214px
;
height
:
214px
;
position
:
absolute
;
top
:
150px
;
left
:
147px
;
/*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>
<script type=
"text/javascript"
>
$(
function
(){
var
timeOut =
function
(){
//超时函数
$(
"#lotteryBtn"
).rotate({
angle:0,
duration: 10000,
animateTo: 2160,
//这里是设置请求超时后返回的角度,所以应该还是回到最原始的位置,2160是因为我要让它转6圈,就是360*6得来的
callback:
function
(){
alert(
'网络超时'
)
}
});
};
var
rotateFunc =
function
(awards,angle,text){
//awards:奖项,angle:奖项对应的角度
$(
'#lotteryBtn'
).stopRotate();
$(
"#lotteryBtn"
).rotate({
angle:0,
duration: 5000,
animateTo: angle+1440,
//angle是图片上各奖项对应的角度,1440是我要让指针旋转4圈。所以最后的结束的角度就是这样子^^
callback:
function
(){
alert(text)
}
});
};
$(
"#lotteryBtn"
).rotate({
bind:
{
click:
function
(){
var
time = [0,1];
time = time[Math.floor(Math.random()*time.length)];
if
(time==0){
timeOut();
//网络超时
}
if
(time==1){
var
data = [1,2,3,0];
//返回的数组
data = data[Math.floor(Math.random()*data.length)];
if
(data==1){
rotateFunc(1,157,
'恭喜您抽中的一等奖'
)
}
if
(data==2){
rotateFunc(2,247,
'恭喜您抽中的二等奖'
)
}
if
(data==3){
rotateFunc(3,22,
'恭喜您抽中的三等奖'
)
}
if
(data==0){
var
angle = [67,112,202,292,337];
angle = angle[Math.floor(Math.random()*angle.length)]
rotateFunc(0,angle,
'很遗憾,这次您未抽中奖'
)
}
}
}
}
});
})
</script>
jQuery抽奖插件 jQueryRotate的更多相关文章
- html5网页动画总结--jQuery旋转插件jqueryrotate
CSS3 提供了多种变形效果,比如矩阵变形.位移.缩放.旋转和倾斜等等,让页面更加生动活泼有趣,不再一动不动.然后 IE10 以下版本的浏览器不支持 CSS3 变形,虽然 IE 有私有属性滤镜(fil ...
- jquery抽奖插件+概率计算
写了一个抽奖的jquery插件和计算概率的方法, 结合起来就是一个简单的概率抽奖, 不过实际项目中基本不会把抽奖概率的计算放在前端处理~. demo lottery.jquery.js $.fn.ex ...
- jQuery旋转插件jqueryrotate 图片旋转
"jquery.rotate.min.js"是jQuery旋转rotate插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .O ...
- jQuery旋转插件—rotate-摘自网友
jQuery旋转插件—rotate 时间:2013年01月03日作者:愚人码头查看次数:5,660 views评论次数:6条评论 网上发现一个很有意思的jQuery旋转插件,支持Internet Ex ...
- jQuery旋转插件—rotate
jQuery旋转插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .Opera 9 .Google Chrome rotate(angle) 正值表 ...
- 深入学习jQuery自定义插件
原文地址:jQuery自定义插件学习 1.定义插件的方法 对象级别的插件扩展,即为jQuery类的实例增加方法, 调用:$(选择器).函数名(参数); $(‘#id’).myPlugin(o ...
- [jQuery]jQuery DataTables插件自定义Ajax分页实现
前言 昨天在博客园的博问上帮一位园友解决了一个问题,我觉得有必要记录一下,万一有人也遇上了呢. 问题描述 园友是做前端的,产品经理要求他使用jQuery DataTables插件显示一个列表,要实现分 ...
- 使用jQuery.form插件,实现完美的表单异步提交
传送门:异步编程系列目录…… 时间真快,转眼一个月快结束了,一个月没写博客了!手开始生了,怎么开始呢…… 示例下载:使用jQuery.form插件,实现完美的表单异步提交.rar 月份的尾巴,今天的主 ...
- 为jQuery写插件
很多场合,我们都会调用jQuery的插件去完成某个功能,比如slider. 如下图,做一个div,通过“$( "#slider" ).slider();”的方式直接将div变成sl ...
随机推荐
- opencart3如何安装模板
opencart 3模板采用twig模式,安装模板也有点不大一样,随ytkah一起来看看opencart3如何安装模板吧1.下载模板文件,用ftp上传到对应的位置,一般有几个文件夹,比如:admin. ...
- CoreData 执行executefetchrequest卡死解决办法
在大量使用GCD和block以后发现程序会卡死在executefetchrequest执行. 反复测试无果.添加锁也无效.想来想去没发现问题. 容忍了就当人品问题.2天以后实在忍无可忍. 替换perf ...
- C++编译器将自动为类产生四个缺省的函数
构造函数.析构函数与赋值函数是每个类最基本的函数.它们太普通以致让人容易麻痹大意, 其实这些貌似简单的函数就象没有顶盖的下水道那样危险. 每个类只有一个析构函数和一个赋值函数,但可以有多个构造函数(包 ...
- Cocos Creator 资源加载(笔记)
cc.loader 加载资源动态加载资源要注意两点,一是所有需要通过脚本动态加载的资源,都必须放置在 resources 文件夹或它的子文件夹下.resources 需要在 assets 文件夹中手工 ...
- C# 并发编程 · 经典实例
http://www.cnblogs.com/savorboard/p/csharp-concurrency-cookbook.html 异步基础 任务暂停,休眠 异步方式暂停或者休眠任务,可以使用 ...
- python安装包API文档
在python开发过程中,经常会使用第三方包,或者内置的包. 那么这些包,具体有哪些选项,有哪些方法,你知道吗?下面介绍一种万能方法. 使用命令:<注意,命令里python显示的API版本是根据 ...
- 强迫症犯了,忍不住赞一下slf4j包Logger.java的优雅代码
如下是slf4j-api包下的Logger接口类里其中几个方法的声明: package org.slf4j; public interface Logger { /** * Log a message ...
- 关于绕过域名(ip)校验的一些小知识
这篇文章最开始只是想写一个关于绕过referer的方法,写着写着发现和ssrf以及url跳转的一些手法类似,于是把这两种也加上了 对referer做校验一般是对csrf进行防范的手段之一,但是很多时候 ...
- window中的attrib命令
attrib -s -h -r autorun.infattrib +s +h +r autorun.infattrib -s -h -r my.icoattrib +s +h +r my.ico
- PHP插入数据库代码,编辑,删除
插入代码 $action=$_GET['action']; switch($action){ //添加记录 case"add"; $mail = trim(htmlspecialc ...