实现代码

网页中引用

<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>
html
<div class="ly-plate">

  <div class="rotate-bg"></div>
    <div class="lottery-star"><img src="rotate-static.png" id="lotteryBtn"></div>
</div>
css
<style type="text/css">

*{padding:0;margin:0}
body{
    text-aligncenter;
    background-color#1664ad;
}
.ly-plate{
    position:relative;
    width:509px;
    height:509px;
    margin50px auto;
}
.rotate-bg{
    width509px;
    height509px;
    backgroundurl(ly-plate.png);
    positionabsolute;
    top0;
    left0;
    margin-top0%;
}
.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{
    cursorpointer;
    positionabsolute;
    top:0;
    left:0;
    *left:-107px
}
</style>
JS
<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来源:http://www.jq22.com/jquery-info308
 

最新文章

  1. rigidbody2D.velocity 提示缺少using?用的unity5?
  2. 如何把一个excel工作薄中N个工作表复制到另一个工作薄中
  3. ruby中http请求方法整理
  4. 给app增加itunes文件共享支持的功能
  5. MySQL添加字段和删除字段
  6. 设置java jvm(虚拟机) 的内存在大小
  7. [C:\Users\Administrator\.IntelliJIdea2016.1\system\tomcat\Unnamed_demo_2\work\Catalina\localhost\demo\org\apache\jsp\index_jsp.java]
  8. HDU4010 Query on The Trees(LCT)
  9. linux操作系统死机处理办法
  10. ios添加pre和post build action
  11. 跟我一起写Makefile-陈皓
  12. 谈谈JavaScript代码混淆
  13. 记住密码&quot;功能的正确设计
  14. react 实用的性能优化方式
  15. C语言中switch case语句可变参实现方法(case 参数 空格...空格 参数 :)
  16. Linux上程序调试的基石(2)--GDB
  17. Apache JMeter压力测试实例
  18. 使用subline作为Stata外部编辑器,并实现代码高亮
  19. Python开发——面向对象【类、实例】
  20. Selenium:HTML测试报告

热门文章

  1. maven build resources
  2. python基础(1)-helloworld
  3. 图片居中table-cell
  4. C语言进阶之路(一)----C语言的内存四区模型
  5. ASP.NET MVC案例教程(一) 准备
  6. zw·10倍速大数据与全内存计算
  7. [openjudge-贪心]装箱问题
  8. MySQL MHA 报错处理
  9. 使用pm2-zabbix监控node工程
  10. DataFrame数据转为list,再逐行写入Excel