Giter VIP home page Giter VIP logo

jfortune's Introduction

jfortune travis

A jquery plugin to make wheel of fortunes (roulettes)

Working examples:

Description

Provides an UI component to make roulettes effects and provides methods to handle the prices on which the roulette stops.

Usage

// You can initialize the roulette by specifying the number of elements
$(selector).roulette(8);

// Or by passing an array of elements
$(selector).roulette([{description: '1000 u$s'}, {description: '200 u$s'}]);

// Array elements can also be arrays of elements to allow for split wedges
$(selector).roulette([
    {description: '1000 u$s'}, 
    {description: '200 u$s'},
    [{description: '100 u$s'},{description: '5000 u$s'},{description: '100 u$s'}]
    ]);

// Or you can fully configurate the roulette behaviour
$(selector).roulette({
  prices: [{description: "1000 u$s"}, {description: "200 u$s"}],
  duration: 3000, // The amount of milliseconds the roulette to spin
  separation: 2, // The separation between each roulette price
  min_spins: 10, // The minimum number of spins 
  max_spins: 15, // The maximum number of spins
  clockWise: true, // The direction the wheel will spin
  onSpinBounce: function() {
    Sounds.play('taka');
  } // A callback to be called each time the roulette hits a price bound.
})

// After initialization you can spin the wheel and it will turn to a random
// position.
$(selector).spin();

// Or you can specify a predefined position
$(selector).spin(4);

// The spin methods returns a promise, which its first arguments is the object that
// is at that position (only if you have used the second form of initilization)
$(selector).spin().then(function(price) {
  console.log(price.description);
});

// or you can specify a fixed price
$(selector).spin(1).spin().then(function(price) {
  console.log(price.description); // "200 u$s"
});

Usage notes

The plugin must be initiated using and array of elements or a number. Both, the array length or the number's value, must be conscistent with the number of positions your roulette's image has, this is not magic. (yet).

At this moment, the css' styles for the roulette animation are hard-coded inside the plugin. This has been done on porpouse to not requiring external files.

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.