360*(jsn.weeks || 4)是什么意思
下边是js中的代码
function turntableDraw(obj,jsn)
{
"use strict";
this.draw = {};
this.draw.obj = $(obj);
this.draw.objClass = $(obj).attr("class");
this.draw.newClass = "rotary"+"new"+parseInt(Math.random()*1000);
var _jiaodu = parseInt(360/jsn.share);
var _yuan = 360*(jsn.weeks || 4);
var _str = "";
var _speed = jsn.speed || "2s";
var _velocityCurve = jsn.velocityCurve || "ease";
var _this = this;
for(var i=1;i<=jsn.share;i++)
{
_str+="."+this.draw.newClass+i+"{";
_str+="transform:rotate("+((i-1)*_jiaodu+_yuan)+"deg);";
_str+="-ms-transform:rotate("+((i-1)*_jiaodu+_yuan)+"deg);";
_str+="-moz-transform:rotate("+((i-1)*_jiaodu+_yuan)+"deg);";
_str+="-webkit-transform:rotate("+((i-1)*_jiaodu+_yuan)+"deg);";
_str+="-o-transform:rotate("+((i-1)*_jiaodu+_yuan)+"deg);";
_str+="transition: transform "+_speed+" "+_velocityCurve+";";
_str+="-moz-transition: -moz-transform "+_speed+" "+_velocityCurve+";";
_str+="-webkit-transition: -webkit-transform "+_speed+" "+_velocityCurve+";";
_str+="-o-transition: -o-transform "+_speed+" "+_velocityCurve+";";
_str+="}";
_str+="."+this.draw.newClass+i+"stop{";
_str+="transform:rotate("+((i-1)*_jiaodu)+"deg);";
_str+="-ms-transform:rotate("+((i-1)*_jiaodu)+"deg);";
_str+="-moz-transform:rotate("+((i-1)*_jiaodu)+"deg);";
_str+="-webkit-transform:rotate("+((i-1)*_jiaodu)+"deg);";
_str+="-o-transform:rotate("+((i-1)*_jiaodu)+"deg);";
_str+="}";
};
$(document.head).append("<style>"+_str+"</style>");
_speed = _speed.replace(/s/,"")*1000;
this.draw.startTurningOk = false;
this.draw.goto=function(ind){
if(_this.draw.startTurningOk){return false};
_this.draw.obj.attr("class",_this.draw.objClass+" "+_this.draw.newClass+ind);
_this.draw.startTurningOk = true;
setTimeout(function(){
_this.draw.obj.attr("class",_this.draw.objClass+" "+_this.draw.newClass+ind+"stop");
if(jsn.callback)
{
_this.draw.startTurningOk = false;
jsn.callback(ind);
};
},_speed+10);
return _this.draw;
};
return this.draw;
};
下边是html页面的代码
<script>
$(".box .img01").load(function() {
var obj = $(".drawBtn");
var hei = $(this).height();//获取当前图片的高度
var hei2 = obj.height();//获取点击的那个指针图片的高度
obj.css("top",(hei - hei2)/2);//给指针设置高度为两个值相减的一半
});
$(".box1 .img01").load(function() {
var obj = $(".drawBtn2");
var hei = $(this).height();
var hei2 = obj.height();
obj.css("top",(hei - hei2)/2);
});
</script>
<script>
//share份额[数字没有默认],
//speed速度[单位s,最小0.1s],
//velocityCurve速度曲线[linear匀速,ease慢快慢,ease-in慢慢开始,ease-out慢慢结束,ease-in-out慢快慢等,用的是css3的速度曲线],可以不写,ease默认值;
//callback回调函数
//weeks几周[默认2周,可以不写]
//几份和回调函数这两个参数是必填
function callbackA(ind)
{
alert("第一个回调"+ind);
};
function callbackB(ind)
{
alert("第二个回调"+ind);
};
var newdraw =new turntableDraw('.drawBtn',{
share:8,
speed:"3s",
velocityCurve:"ease",
weeks:6,
callback:function(num)
{
callbackA(num);
},
});
var newdraw2 =new turntableDraw('.drawBtn2',{
share:12,
speed:"3s",
velocityCurve:"ease",
weeks:6,
callback:function(num)
{
callbackB(num);
},
});
$(".drawBtn").click(function(event) {
//ajax
var hitArea = [2,5,8];
var hit = hitArea.length-1;
//getRandomNum(0, hitArea.length-1);
newdraw.goto(parseInt(Math.random()*8)+1);
});
$(".drawBtn2").click(function(event) {
//ajax
newdraw2.goto(parseInt(Math.random()*12)+1);
});
</script>
怎样控制中奖的概率为0
黑心企业,才不告诉你o(´^`)o