Skip to content

Commit

Permalink
Fixed #12
Browse files Browse the repository at this point in the history
Thanks for reporting :)

I've added new parameter `isStopping` that indicates if the machine is
displaying the stop animation.

In this state, the function `stop()` still returning the future active
element and the parameter `isRunning` still `true` until the machine
fully stops.
  • Loading branch information
josex2r committed Jul 21, 2015
1 parent 1bce2a0 commit d787186
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Check if the machine is running:
machine.isRunning; //Returns boolean
```

Check if the machine is stopping:

```javascript
machine.isStopping; //Returns boolean
```

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

```javascript
Expand All @@ -73,13 +79,13 @@ Params must be an object, optionally containing the next parammeters:
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
Expand All @@ -97,7 +103,7 @@ Stop animation if the element is above or below the screen
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):

```javascript
Expand All @@ -107,11 +113,11 @@ $('#foo').slotMachine({
}
});
```

## Authors

[Jose Luis Represa](https://github.com/josex2r)

##License

jQuery-SlotMachine is released under the [MIT License](http://opensource.org/licenses/MIT).
jQuery-SlotMachine is released under the [MIT License](http://opensource.org/licenses/MIT).
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jQuery-SlotMachine",
"description": "A simple jQuery plugin to make slot machine animation effect",
"version": "2.0.10",
"version": "2.0.11",
"keywords": [
"slots",
"gambling",
Expand Down
10 changes: 8 additions & 2 deletions dist/jquery.slotmachine.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! SlotMachine - v2.0.10 - 2015-05-28
/*! SlotMachine - v2.0.11 - 2015-07-21
* https://github.com/josex2r/jQuery-SlotMachine
* Copyright (c) 2015 Jose Luis Represa; Licensed MIT */
;(function($, window, document, undefined){
Expand Down Expand Up @@ -178,6 +178,8 @@
this.futureActive = null;
//Machine is running?
this.isRunning = false;
//Machine is stopping?
this.isStopping = false;
//Current active element
this.active = this.settings.active;

Expand Down Expand Up @@ -433,6 +435,8 @@
SlotMachine.prototype.stop = function( showGradient ){
if(!this.isRunning){
return;
} else if (this.isStopping) {
return this.futureActive;
}
var self = this;

Expand All @@ -442,6 +446,7 @@
this._setAnimationFX(FX_SLOW, showGradient === undefined ? true : showGradient);

this.isRunning = true;
this.isStopping = true;

//Set current active element
this.active = this.getVisibleTile();
Expand All @@ -461,7 +466,6 @@

//Update last choosen element index
this.active = this.futureActive;
this.futureActive = null;

//Get delay
var delay = this.settings.delay * 3;
Expand All @@ -471,7 +475,9 @@
marginTop : this.getTileOffset(this.active)
}, delay, 'easeOutBounce', function (){

self.isStopping = false;
self.isRunning = false;
self.futureActive = null;

//Filter callbacks
/*
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.slotmachine.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-slotmachine",
"version": "2.0.10",
"version": "2.0.11",
"engines": {
"node": ">= 0.8.0"
},
Expand Down
2 changes: 1 addition & 1 deletion slotmachine.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"winning",
"machine"
],
"version": "2.0.10",
"version": "2.0.11",
"download": "https://github.com/josex2r/jQuery-SlotMachine",
"homepage": "https://github.com/josex2r/jQuery-SlotMachine",
"demo": "http://josex2r.github.io/jQuery-SlotMachine/",
Expand Down
Loading

0 comments on commit d787186

Please sign in to comment.