Coder Social home page Coder Social logo

jquery-slotmachine's Introduction

#jQuery-SlotMachine Build Status Dependency Status devDependency Status

A simple, lightweight jQuery plugin to make slot machine animation effect.

[Check the example page!] (http://josex2r.github.io/jQuery-SlotMachine/)

Installation

Install the component using Bower:

$ bower install jquery-slotmachine --save

Include the script located in dist folder after the jQuery library:

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

Usage

Creating the machine:

var machine = $(foo).slotMachine( params );

Shuffle:

machine.shuffle( repeat, onStopCallback ); //No args to make rotate infinitely

Change the selected element:

machine.prev(); //Previous element

machine.next(); //Next element

Get selected element:

machine.active; //Current element index

Get the next selected element:

machine.futureActive; //Future active element index

Check if the machine is running:

machine.isRunning; //Returns boolean

Change spin result, if the returned value is out of bounds, the element will be randomly choosen:

machine.setRandomize(foo); //foo must be a function (should return int) or an int

Params

Params must be an object, optionally containing the next parammeters:

active

Set the first element

active: 0

delay

Set spin animation time

delay: 200

auto

Pass an int as miliseconds to make the machine auto rotate

repeat: false

stopHidden (currently disabled)

Stop animation if the element is above or below the screen

stopHidden: true

randomize

Pass a function to select your own random element. This function must return an integer between 0 (first element) and max number of elements.

randomize: function(activeElementIndex){} //activeElementIndex = current selected index

Example (this machine always shows first element):

$('#foo').slotMachine({
	randomize : function(activeElementIndex){
		return 0;
	}
});

Authors

Jose Luis Represa

##License

jQuery-SlotMachine is released under the MIT License.

jquery-slotmachine's People

Contributors

josex2r avatar jmwohl avatar

Watchers

joy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.