js抽奖插件jQuery-SlotMachine

所属分类:其他-游戏

 20492  252  查看评论 (2)
分享到微信朋友圈
X
js抽奖插件jQuery-SlotMachine ie兼容12

 jQuery现在不是必需的!这个名字只是继承以前的。

安装

使用 npm 安装组件:

npm install jquery-slotmachine --save

使用 Bower 安装组件:

bower install jquery-slotmachine --save

例子

<div id="machine">
  <div>Madrid</div>
  <div>London</div>
  <div>New York</div>
</div>

<script>
const el = document.querySelector('#machine');
const machine = new SlotMachine(el, {
  active: 1,
  delay: 450,
  auto: 1500
});
</script>

使用

包括位于 dist 文件夹中的脚本:

<script src="/path/to/slotmachine.min.js"></script>

然后你可以让它在你的应用程序中调用lib:

const element = document.getElementById('my-machine');
const machine = new SlotMachine(element, { /* options */ });

如果你喜欢jQuery样式,那么在jQuery库之后导入包装器:

<script src="/path/to/jquery.min.js"></script>
<script src="/path/to/slotmachine.min.js"></script>
<script src="/path/to/jquery.slotmachine.min.js"></script>
$(document).ready(function(){
  $('#my-machine').slotMachine({ /* options */ });
});

设置

使用函数的第一个参数将对象与选项传递:

const machine = new SlotMachine(element, {
  active: 2,
  auto: true
});
NameTypeDefaultDescription
activeNumber0The initial visible element (0 means the first one)
delayNumber200Duration (in ms) of each spin
autoBooleanfalseRuns the carousel mode when creating the machine
spinsNumber5Number of spins after stop in carousel mode
randomizeFunctionnullFunction (returns number) that is going to be called to set the next active element
onCompleteFunctionnullCallback after each spin in carousel mode
inViewportBooleantrueOnly spin when the machine is inside the viewport
directionStringupThe spin direction (possible values are up and down)
transitionStringease-in-outThe CSS transition

属性

  • machine.nextActive: 获取下一个活动元素(仅在改组时)。

  • machine.nextIndex: 根据当前方向的下一个元素索引。

  • machine.prevIndex: 根据当前方向的Prev元素索引。

  • machine.random: 获取机器边界之间的rando索引。

  • machine.running: 检查机器是否正在运行。

  • machine.stopping: 检查机器是否正在停止。

  • machine.visible: 检查机器是否可见。

  • machine.visibleTile: 获取机器视窗中的当前可见元素。

  • machine.active: 活动设置的别名。

  • machine.randomize: 随机化设置的别名。

  • machine.direction: 方向设置的别名。

  • machine.transition: 转换设置的别名。

相关插件-游戏

jquery+css3模仿win7自带蜘蛛纸牌(原创)

渣渣码手无聊写的,仅供娱乐学习,代码思路全是自己想的,绝无抄袭
  游戏
 28625  305

js打地鼠

js打地鼠游戏,此游戏代码结构清晰、注释全,非常适合学习参考,要的抓紧下了
  游戏
 28711  327

幸运大抽奖适用移动端

幸运大抽奖适用移动端
  游戏
 38798  389

jquery天天爱消除小游戏

jquery实现的简易版天天爱消除,简单效果好,功能自己扩展。
  游戏
 26663  306

讨论这个项目(2)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    优昙 0
    2021/12/9 18:45:56
    中奖物品是怎么设置的 回复
    愉悦谎言 0
    2019/7/5 15:51:55
    怎么控制概率啊 回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复