JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Slot Machine</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="google-site-verification" content="d58Et_hG0KrLc6xKv03J8U5NA6jqak0kCFxBaz7Y1MM" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/app.css">
</head>
<body>
<div class="container">
<div class="slotwrapper" id="example1">
<ul>
<li>0</li>
<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 class="text-danger">9</li>
</ul>
<ul>
<li>0</li>
<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 class="text-danger">9</li>
</ul>
<ul>
<li>0</li>
<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 class="text-danger">9</li>
</ul>
</div>
<div >
<button type="button" class="btn btn-success btn-lg"...
CSS
body {
margin-top: 60px;
}
.slotwrapper {
overflow: hidden;
display: inline-block;
border: 1px solid #000;
height: 200px;
}
.slotwrapper ul {
padding: 0;
margin: 0;
list-style: none;
position: relative;
float: left;
}
.slotwrapper ul {
width: 200px;
height:200px;
font-size: 200px;
line-height: 200px;
text-align: center;
}
.slotwrapper ul li img {
vertical-align: top;
}
@media screen and (max-width: 1200px) {
.slotwrapper {
width: 100%;
}
.slotwrapper ul {
width: 33%;
}
}
@media screen and (max-width: 768px) {
.slotwrapper {
height: 100px;
}
.slotwrapper ul {
height:100px;
font-size: 100px;
line-height: 100px;
}
}
JavaScript
var startSeqs = {};
var startNum = 0;
// jQuery FN
$.fn.playSpin = function (options) {
if (this.length) {
if ($(this).is(':animated')) return; // Return false if this element is animating
startSeqs['mainSeq' + (++startNum)] = {};
$(this).attr('data-playslot', startNum);
var total = this.length;
var thisSeq = 0;
// Initialize options
if (typeof options == 'undefined') {
options = new Object();
}
// Pre-define end nums
var endNums = [];
if (typeof options.endNum != 'undefined') {
if ($.isArray(options.endNum)) {
endNums = options.endNum;
} else {
endNums = [options.endNum];
}
}
for (var i = 0; i < this.length; i++) {
if (typeof endNums[i] == 'undefined') {
endNums.push(0);
}
}
startSeqs['mainSeq' + startNum]['totalSpinning'] = total;
return this.each(function () {
options.endNum = endNums[thisSeq];
startSeqs['mainSeq' + startNum]['subSeq' + (++thisSeq)] = {};
startSeqs['mainSeq' + startNum]['subSeq' + thisSeq]['spinning'] = true;
var track = {
total: total,
mainSeq: startNum,
subSeq: thisSeq
};
(new slotMachine(this, options, track));
});
}
};
$.fn.stopSpin = function () {
if (this.length) {
if (!$(this).is(':animated')) return; // Return false if this element is not animating
if ($(this)[0].hasAttribute('data-playslot')) {
$.each(startSeqs['mainSeq' + $(this).attr('data-playslot')], function(index, obj) {
obj['spinning'] = false;
});
}
}
};
var slotMachine = function (el, options, track) {
var slot = this;
slot.$el = $(el);
slot.defaultOptions = {
easing: 'swing', // String:...