JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<ul class="slot">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
</ul>
<br />
<input type="button" value="Get numbers" id="playBtn" />
</div>
CSS
* {
box-sizing: border-box;
}
.slot li {
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
}
body {
padding:3px;
font-family: sans-serif;
font-size: 16px;
}
ul {
padding: 0;
margin: 0;
list-style: none;
}
.jSlots-wrapper {
overflow: hidden;
height: 40px;
display: inline-block;
/* to size correctly, can use float too, or width*/
border: 1px solid #999;
}
.slot {
float: left;
}
JavaScript
var getNewNumber = function( spinner ) {
/* Some ASYNC!! ajax stuff, than when done: */
//the returned data is a array, eg [1,3,4]
//for the spinner to stop at 134
spinner.options.endNumbers = [1, 3, 4];
};
$(document).ready(function () {
$('.slot').jSlots({
spinner: '#playBtn',
endNumbers: [],
onStart: getNewNumber
});
});
/*
* jQuery jSlots Plugin
* http://matthewlein.com/jslot/
* Copyright (c) 2011 Matthew Lein
* Version: 1.0.2 (7/26/2012)
* Dual licensed under the MIT and GPL licenses
* Requires: jQuery v1.4.1 or later
*/
(function ($) {
$.jSlots = function (el, options) {
var base = this;
base.$el = $(el);
base.el = el;
base.$el.data("jSlots", base);
base.init = function () {
base.options = $.extend({}, $.jSlots.defaultOptions, options);
base.setup();
base.bindEvents();
};
// --------------------------------------------------------------------- //
// DEFAULT OPTIONS
// --------------------------------------------------------------------- //
$.jSlots.defaultOptions = {
number: 3, // Number: number of slots
winnerNumber: 1, // Number or Array: list item number(s) upon which to trigger a win, 1-based index, NOT ZERO-BASED
spinner: '', // CSS Selector: element to bind the start event to
spinEvent: 'click', // String: event to start slots on this event
onStart: $.noop, // Function: runs on spin start,
onEnd: $.noop, // Function: run on spin end. It is passed (finalNumbers:Array). finalNumbers gives the index of the li each slot stopped on in order.
onWin: $.noop, // Function: run on winning number. It is passed (winCount:Number, winners:Array)
easing: 'swing', // String: easing type for final spin
time: 7000, // Number: total time of spin animation
loops: 6, // Number:...