diff --git a/bower.json b/bower.json index 4d976b1..1e08500 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.3.0", + "version": "2.3.1", "keywords": [ "slots", "gambling", diff --git a/dist/jquery.slotmachine.js b/dist/jquery.slotmachine.js index 63c2d3b..b10e950 100644 --- a/dist/jquery.slotmachine.js +++ b/dist/jquery.slotmachine.js @@ -1,14 +1,14 @@ -/*! SlotMachine - v2.3.0 - 2016-02-02 +/*! SlotMachine - v2.3.1 - 2016-02-09 * https://github.com/josex2r/jQuery-SlotMachine * Copyright (c) 2016 Jose Luis Represa; Licensed MIT */ 'use strict'; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* - * jQuery Slot Machine v2.1.0 + * jQuery Slot Machine v2.3.1 * https:// github.com/josex2r/jQuery-SlotMachine * * Copyright 2014 Jose Luis Represa @@ -66,7 +66,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }); } - var Timer = function () { + var Timer = (function () { function Timer(cb, delay) { _classCallCheck(this, Timer); @@ -86,9 +86,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons _createClass(Timer, [{ key: '_start', value: function _start() { - this.timer = setTimeout(function cb() { + this.timer = setTimeout((function cb() { this.cb.call(this); - }.bind(this), this.delay); + }).bind(this), this.delay); } }, { key: 'cancel', @@ -131,7 +131,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }]); return Timer; - }(); + })(); /** * @desc Class - Makes Slot Machine animation effect @@ -140,7 +140,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * @return jQuery node - Returns jQuery selector with some new functions (shuffle, stop, next, auto, active) */ - var SlotMachine = function () { + var SlotMachine = (function () { function SlotMachine(element, options) { _classCallCheck(this, SlotMachine); @@ -400,7 +400,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } else { this.$container.animate({ marginTop: this.direction.to - }, delay, 'linear', function cb() { + }, delay, 'linear', (function cb() { // Reset top position this._marginTop = this.direction.first; @@ -410,7 +410,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // Repeat animation this.shuffle(spins - 1); } - }.bind(this)); + }).bind(this)); } return this.futureActive; @@ -465,7 +465,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // Perform animation this.$container.animate({ marginTop: this.getTileOffset(this.active) - }, delay, 'easeOutBounce', function cb() { + }, delay, 'easeOutBounce', (function cb() { this.stopping = false; this.running = false; @@ -477,13 +477,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (typeof this._oncompleteStack[1] === 'function') { this._oncompleteStack[1].apply(this, [this.active]); } - }.bind(this)); + }).bind(this)); // Disable blur - this.raf(function cb() { + this.raf((function cb() { this._fade = false; this._animationFX = FX_STOP; - }.bind(this), delay / 1.75); + }).bind(this), delay / 1.75); return this.active; } @@ -496,20 +496,20 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons key: 'auto', value: function auto() { if (!this.running) { - this._timer = new Timer(function cb() { + this._timer = new Timer((function cb() { if (typeof this.settings.randomize !== 'function') { this.futureActive = this.next; } if (!this.visible && this.settings.stopHidden === true) { - this.raf(function cb2() { + this.raf((function cb2() { this._timer.reset(); - }.bind(this), 500); + }).bind(this), 500); } else { - this.shuffle(this.settings.spins, function cb2() { + this.shuffle(this.settings.spins, (function cb2() { this._timer.reset(); - }.bind(this)); + }).bind(this)); } - }.bind(this), this.settings.auto); + }).bind(this), this.settings.auto); } } @@ -702,7 +702,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var delay = this.settings.delay / 4, $elements = this.$slot.add(this.$tiles); - this.raf(function cb() { + this.raf((function cb() { this._fxClass = FX_SPEED; if (this.fade !== true || FX_SPEED === FX_STOP) { @@ -710,7 +710,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } else { $elements.addClass(FX_GRADIENT); } - }.bind(this), delay); + }).bind(this), delay); } /** @@ -726,7 +726,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }]); return SlotMachine; - }(); + })(); /* * Create new plugin instance if needed and return it diff --git a/dist/jquery.slotmachine.min.js b/dist/jquery.slotmachine.min.js index fe2b924..cbf946f 100644 --- a/dist/jquery.slotmachine.min.js +++ b/dist/jquery.slotmachine.min.js @@ -1,4 +1,4 @@ -/*! SlotMachine - v2.3.0 - 2016-02-02 +/*! SlotMachine - v2.3.1 - 2016-02-09 * https://github.com/josex2r/jQuery-SlotMachine * Copyright (c) 2016 Jose Luis Represa; Licensed MIT */ "use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function a(a,b){for(var c=0;c"+("."+h+'{-webkit-filter: blur(5px);-moz-filter: blur(5px);-o-filter: blur(5px);-ms-filter: blur(5px);filter: blur(5px);filter: url("data:image/svg+xml;utf8,'+b+'");filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius="5")}')+("."+i+'{-webkit-filter: blur(3px);-moz-filter: blur(3px);-o-filter: blur(3px);-ms-filter: blur(3px);filter: blur(3px);filter: url("data:image/svg+xml;utf8,'+c+'");filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius="3")}')+("."+j+'{-webkit-filter: blur(1px);-moz-filter: blur(1px);-o-filter: blur(1px);-ms-filter: blur(1px);filter: blur(1px);filter: url("data:image/svg+xml;utf8,'+d+'");filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius="1")}')+("."+k+"{")+"-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0,0,0,0)), color-stop(25%, rgba(0,0,0,1)), color-stop(75%, rgba(0,0,0,1)), color-stop(100%, rgba(0,0,0,0)) );"+('mask: url("data:image/svg+xml;utf8,'+e+'");')+"}")}),"function"!=typeof a.easing.easeOutBounce&&a.extend(a.easing,{easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*(7.5625*b*b)+c:2/2.75>b?d*(7.5625*(b-=1.5/2.75)*b+.75)+c:2.5/2.75>b?d*(7.5625*(b-=2.25/2.75)*b+.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+.984375)+c}});var m=function(){function a(b,c){return _classCallCheck(this,a),this.cb=b,this.initialDelay=c,this.delay=c,this.deferred=jQuery.Deferred(),this.startTime=null,this.timer=null,this.running=!1,this.resume(),this}return _createClass(a,[{key:"_start",value:function(){this.timer=setTimeout(function(){this.cb.call(this)}.bind(this),this.delay)}},{key:"cancel",value:function(){this.running=!1,clearTimeout(this.timer)}},{key:"pause",value:function(){this.running&&(this.delay-=(new Date).getTime()-this.startTime,this.cancel())}},{key:"resume",value:function(){this.running||(this.running=!0,this.startTime=(new Date).getTime(),this._start())}},{key:"reset",value:function(){this.cancel(),this.delay=this.initialDelay,this._start()}},{key:"add",value:function(a){this.pause(),this.delay+=a,this.resume()}}]),a}(),n=function(){function c(b,d){_classCallCheck(this,c),this.element=b,this.settings=a.extend({},g,d),this.defaults=g,this.name=f,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.running=!1,this.stopping=!1,this.active=this.settings.active,this.$slot.css("overflow","hidden"),this.$container=this.$tiles.wrapAll('
').parent(),this._maxTop=-this.$container.height(),this._initFakeTiles(),this._minTop=-this._$fakeFirstTile.outerHeight(),this._initDirection(),this._marginTop=this.direction.initial,this.settings.auto!==!1&&(this.settings.auto===!0?this.shuffle():this.auto())}return _createClass(c,[{key:"_initFakeTiles",value:function(){this._$fakeFirstTile=this.$tiles.last().clone(),this._$fakeLastTile=this.$tiles.first().clone(),this.$container.prepend(this._$fakeFirstTile),this.$container.append(this._$fakeLastTile)}},{key:"_initDirection",value:function(){this._direction={selected:"down"===this.settings.direction?"down":"up",up:{key:"up",initial:this.getTileOffset(this.active),first:0,last:this.getTileOffset(this.$tiles.length),to:this._maxTop,firstToLast:this.getTileOffset(this.$tiles.length),lastToFirst:0},down:{key:"down",initial:this.getTileOffset(this.active),first:this.getTileOffset(this.$tiles.length),last:0,to:this._minTop,firstToLast:this.getTileOffset(this.$tiles.length),lastToFirst:0}}}},{key:"raf",value:function(a,c){var d=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame,e=(new Date).getTime(),f=function g(){var b=(new Date).getTime(),f=b-e;c>f?d(g):"function"==typeof a&&a()};d(f)}},{key:"getTileOffset",value:function(a){for(var b=0,c=0;a>c;c++)b+=this.$tiles.eq(c).outerHeight();return this._minTop-b}},{key:"_resetPosition",value:function(){this._marginTop=this.direction.initial}},{key:"setRandomize",value:function(a){this.settings.randomize=a,"number"==typeof a&&(this.settings.randomize=function(){return a})}},{key:"prev",value:function(){return this.futureActive=this.prevIndex,this.running=!0,this.stop(!1),this.futureActive}},{key:"next",value:function(){return this.futureActive=this.nextIndex,this.running=!0,this.stop(!1),this.futureActive}},{key:"shuffle",value:function(a,b){var c=this.settings.delay;if("function"==typeof a&&(b=a),b&&(this._oncompleteStack[1]=b),this.running=!0,this._fade=!0,"number"==typeof a)switch(a){case 1:case 2:this._animationFX=j;break;case 3:case 4:this._animationFX=i,c/=1.5;break;default:this._animationFX=h,c/=2}else this._animationFX=h,c/=2;return this.visible||this.settings.stopHidden!==!0?this.$container.animate({marginTop:this.direction.to},c,"linear",function(){this._marginTop=this.direction.first,0>=a-1?this.stop():this.shuffle(a-1)}.bind(this)):this.stop(),this.futureActive}},{key:"stop",value:function(a){if(this.running){if(this.stopping)return this.futureActive;this.$container.clearQueue().stop(!0,!1),this._fade=a===d?!0:a,this._animationFX=j,this.running=!0,this.stopping=!0,this.active=this.visibleTile,null===this.futureActive&&(this.futureActive=this.custom),this.futureActive>this.active?0===this.active&&this.futureActive===this.$tiles.length-1&&(this._marginTop=this.direction.firstToLast):this.active===this.$tiles.length-1&&0===this.futureActive&&(this._marginTop=this.direction.lastToFirst),this.active=this.futureActive;var b=3*this.settings.delay;return this.$container.animate({marginTop:this.getTileOffset(this.active)},b,"easeOutBounce",function(){this.stopping=!1,this.running=!1,this.futureActive=null,"function"==typeof this._oncompleteStack[0]&&this._oncompleteStack[0].apply(this,[this.active]),"function"==typeof this._oncompleteStack[1]&&this._oncompleteStack[1].apply(this,[this.active])}.bind(this)),this.raf(function(){this._fade=!1,this._animationFX=l}.bind(this),b/1.75),this.active}}},{key:"auto",value:function(){this.running||(this._timer=new m(function(){"function"!=typeof this.settings.randomize&&(this.futureActive=this.next),this.visible||this.settings.stopHidden!==!0?this.shuffle(this.settings.spins,function(){this._timer.reset()}.bind(this)):this.raf(function(){this._timer.reset()}.bind(this),500)}.bind(this),this.settings.auto))}},{key:"destroy",value:function(){this._$fakeFirstTile.remove(),this._$fakeLastTile.remove(),this.$tiles.unwrap(),a.data(this.element[0],"plugin_"+f,null)}},{key:"active",get:function(){return this._active},set:function(a){this._active=a,(0>a||a>=this.$tiles.length)&&(this._active=0)}},{key:"visibleTile",get:function(){var a=this.$tiles.first().height(),b=this.$container.css("margin-top"),c=parseInt(b.replace(/px/,""),10);return Math.abs(Math.round(c/a))-1}},{key:"random",get:function(){return Math.floor(Math.random()*this.$tiles.length)}},{key:"custom",get:function(){var a=void 0;if("function"==typeof this.settings.randomize){var b=this.settings.randomize.call(this,this.active);(0>b||b>=this.$tiles.length)&&(b=0),a=b}else a=this.random;return a}},{key:"direction",get:function(){return this._direction[this._direction.selected]},set:function(a){this.running||(this.direction="down"===a?"down":"up")}},{key:"_prevIndex",get:function(){var a=this.active-1;return 0>a?this.$tiles.length-1:a}},{key:"_nextIndex",get:function(){var a=this.active+1;return ac.scrollTop()+c.height(),e=c.scrollTop()>this.$slot.height()+this.$slot.offset().top;return!d&&!e}},{key:"_fxClass",set:function(a){var b=[h,i,j].join(" ");this.$tiles.removeClass(b).addClass(a)}},{key:"_animationFX",set:function(a){var b=this.settings.delay/4,c=this.$slot.add(this.$tiles);this.raf(function(){this._fxClass=a,this.fade!==!0||a===l?c.removeClass(k):c.addClass(k)}.bind(this),b)}},{key:"_marginTop",set:function(a){this.$container.css("margin-top",a)}}]),c}();a.fn[f]=function(b){var c=this,d=void 0;return 1===this.length?d=e(this,b):!function(){var f=c;d=a.map(f,function(a,c){var d=f.eq(c);return e(d,b)})}(),d}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index d289303..b1f34a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-slotmachine", - "version": "2.3.0", + "version": "2.3.1", "engines": { "node": ">= 0.8.0" }, diff --git a/slotmachine.jquery.json b/slotmachine.jquery.json index f56cc00..33bc646 100644 --- a/slotmachine.jquery.json +++ b/slotmachine.jquery.json @@ -11,7 +11,7 @@ "winning", "machine" ], - "version": "2.3.0", + "version": "2.3.1", "download": "https://github.com/josex2r/jQuery-SlotMachine", "homepage": "https://github.com/josex2r/jQuery-SlotMachine", "demo": "http://josex2r.github.io/jQuery-SlotMachine/", diff --git a/src/jquery.slotmachine.js b/src/jquery.slotmachine.js index 5199584..43e8cb5 100644 --- a/src/jquery.slotmachine.js +++ b/src/jquery.slotmachine.js @@ -1,5 +1,5 @@ /* - * jQuery Slot Machine v2.1.0 + * jQuery Slot Machine v2.3.1 * https:// github.com/josex2r/jQuery-SlotMachine * * Copyright 2014 Jose Luis Represa