• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    JavaScript
  • Created about 13 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jQuery slot machine insanity! Turns any list into a slot machine (you provide the insanity)

jQuery jSlots

jSlots is 2k of jQuery slot machine magic. It turns any list (<ol> or <ul>) into a slot machine!

Options

These are the options, with their default values, and what they do

$.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, finalNumbers:Array)
    easing : 'swing',    // String: easing type for final spin. I recommend the easing plugin and easeOutSine, or an easeOut of your choice.
    time : 7000,         // Number: total time of spin animation
    loops : 6            // Number: times it will spin during the animation
};

Usage

Attach jQuery (successfully tested down to v1.4.1)

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

Attach jSlots plugin

<script src="jquery.jSlots.js" charset="utf-8"></script>

Attach easing plugin (optional but HIGHLY recommended for nice animation)

<script src="jquery.easing.1.3.js" charset="utf-8"></script>

Create a list and an element that will spin the slots

<ul class="slot">
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
</ul>

<!-- this button will start the spin -->
<input type="button" id="playBtn" value="play">

Target the list and make it a jSlot!

<script type="text/javascript" charset="utf-8">

    $('.slot').jSlots({
        spinner : '#playBtn',
        winnerNumber : 7
    });

</script>

Styling is up to you, but jSlots supplies a jSlots-wrapper div around your lists that should get overflow: hidden and a height set on it. Here are some recommended styles:

.jSlots-wrapper {
    overflow: hidden; /* to hide the magic */
    height: 20px; /* whatever the height of your list items are */
    display: inline-block; /* to size width correctly, can use float too, or width*/
    border: 1px solid #999;
}

More Repositories

1

jQuery-widowFix

Widow Fix is a jQuery plugin to fix widows, or orphans, or whatever you call themโ€”those single words on their own line. It does this by adding a &nbsp; (non-breaking space) in between the last 2 words. It's super lite and easy to use!
HTML
87
star
2

Ceaser

Ceaser page and JS
CSS
77
star
3

patternizer.js

Canvas library to easily create crazy stripe patterns.
JavaScript
65
star
4

Ceaser-CSS-Easing-tmbundle

TextMate bundle for the Ceaser CSS Easing Equations
JavaScript
43
star
5

jQuery-ViewMaster

A jQuery CSS3 slideshow
CSS
15
star
6

cicadaJS

A tiny JavaScript to create endless nearly non-repeating stripe patterns based on prime (or coprime) numbers
CSS
12
star
7

orbular.js

JavaScript
10
star
8

inline-block-no-space-font

This is an attempt to use a font to get rid of space between inline blocks
CSS
10
star
9

bustify

Bustify breaks an image into a series of boxes and adds 3D transforms to bust it apart
JavaScript
8
star
10

postman-collection-sorter

Sort Postman collections by name
JavaScript
6
star
11

yellowgrid

such a super grid
CSS
5
star
12

custom-chrome-devtools

custom css for chrome dev tools. dark theme w left side check boxes!
5
star
13

Diagnostix.js

A timer wrapper for diagnosing the speed of executing js
JavaScript
2
star
14

regex-share

A share for regex that I use for random things
2
star
15

jQuery-logHandlers

JavaScript
2
star
16

CSS-regionator

JavaScript
2
star
17

more-less

Less Mixin helpers
JavaScript
1
star
18

my-bash-profile

this is my bash profile
Shell
1
star
19

mediaQueryManager.js

manages yo breakpoints
CSS
1
star
20

loopalo

It loops and it los!
JavaScript
1
star
21

preconnect-list

Generate a list of connections based on a .har file
JavaScript
1
star