diff --git a/README.md b/README.md
index 1a393c4..e8e551e 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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
@@ -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
@@ -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).
\ No newline at end of file
+jQuery-SlotMachine is released under the [MIT License](http://opensource.org/licenses/MIT).
diff --git a/bower.json b/bower.json
index 1128b6c..ae0f1cd 100644
--- a/bower.json
+++ b/bower.json
@@ -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",
diff --git a/dist/jquery.slotmachine.js b/dist/jquery.slotmachine.js
index d63297e..46fe2f5 100644
--- a/dist/jquery.slotmachine.js
+++ b/dist/jquery.slotmachine.js
@@ -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){
@@ -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;
@@ -433,6 +435,8 @@
SlotMachine.prototype.stop = function( showGradient ){
if(!this.isRunning){
return;
+ } else if (this.isStopping) {
+ return this.futureActive;
}
var self = this;
@@ -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();
@@ -461,7 +466,6 @@
//Update last choosen element index
this.active = this.futureActive;
- this.futureActive = null;
//Get delay
var delay = this.settings.delay * 3;
@@ -471,7 +475,9 @@
marginTop : this.getTileOffset(this.active)
}, delay, 'easeOutBounce', function (){
+ self.isStopping = false;
self.isRunning = false;
+ self.futureActive = null;
//Filter callbacks
/*
diff --git a/dist/jquery.slotmachine.min.js b/dist/jquery.slotmachine.min.js
index ba22edc..e625a3e 100644
--- a/dist/jquery.slotmachine.min.js
+++ b/dist/jquery.slotmachine.min.js
@@ -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(a,b,c,d){function e(a,b){var c,d,e=this,f=a,g=arguments,h=b;this.running=!1,this.onpause=function(){},this.onresume=function(){},this.cancel=function(){this.running=!1,clearTimeout(d)},this.pause=function(){this.running&&(b-=(new Date).getTime()-c,this.cancel(),this.onpause())},this.resume=function(){this.running||(this.running=!0,c=(new Date).getTime(),d=setTimeout(function(){f.apply(e,Array.prototype.slice.call(g,2,g.length))},b),this.onresume())},this.reset=function(){this.cancel(),this.running=!0,b=h,d=setTimeout(function(){f.apply(e,Array.prototype.slice.call(g,2,g.length))},h)},this.add=function(a){this.pause(),b+=a,this.resume()},this.resume()}function f(b,c){this.element=b,this.settings=a.extend({},i,c),this.defaults=i,this.name=h,this.$slot=a(b),this.$tiles=this.$slot.children(),this.$container=null,this._minTop=null,this._maxTop=null,this._$fakeFirstTile=null,this._$fakeLastTile=null,this._timer=null,this._oncompleteStack=[this.settings.complete],this._spinsLeft=null,this.futureActive=null,this.isRunning=!1,this.active=this.settings.active,this.$slot.css("overflow","hidden"),(this.settings.active<0||this.settings.active>=this.$tiles.length)&&(this.settings.active=0,this.active=0),this.$tiles.wrapAll("