我使用这个jquery jSlots(https://github.com/matthewlein/jQuery-jSlots)使用数字0-9。有什么方法可以让最终结果永远不会落在第一个李的0上?
清晰度:
0129 =错误
1029 =确定
答案 0 :(得分:0)
我已经更新了一些javascript代码,现在应该无法在第一个数字上获得0,但如果你这样做,请告诉我:
https://jsfiddle.net/chc7p4xt/7/
更新了部分:
1
// clone lists
for (var i = base.options.number - 1; i >= 0; i--){
base.allSlots.push( new base.Slot(i) ); //sends i
}
2
// Slot contstructor
base.Slot = function(i) { //recieves i
this.spinSpeed = 0;
this.el = base.$el.clone().appendTo(base.$wrapper)[0];
this.$el = $(this.el);
this.loopCount = 0;
this.number = 0;
this.count = i; //sets i
};
3
if(this.count == 5) //checks if its the first number
{
var endNum = base.randomRange( 1, base.liCount - 1 ); //if so, can't be 0
}
else
{
var endNum = base.randomRange( 1, base.liCount );
}
编辑:在评论中回答您的问题:
if(this.count == 5) //checks if its the first number
{
var endNum = base.randomRange( 8, base.liCount - 1 ); //Changed the 1 to an 8
}
else
{
var endNum = base.randomRange( 1, base.liCount );
}