diff --git a/bower.json b/bower.json index 3593463..aa55fab 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.1.0", + "version": "2.2.0", "keywords": [ "slots", "gambling", diff --git a/dist/jquery.slotmachine.js b/dist/jquery.slotmachine.js index 19b74b8..71a64b6 100644 --- a/dist/jquery.slotmachine.js +++ b/dist/jquery.slotmachine.js @@ -1,15 +1,15 @@ -/*! SlotMachine - v2.1.0 - 2015-07-21 +/*! SlotMachine - v2.2.0 - 2015-11-05 * https://github.com/josex2r/jQuery-SlotMachine * Copyright (c) 2015 Jose Luis Represa; Licensed MIT */ (function($, window, document, undefined) { var pluginName = "slotMachine", defaults = { - active: 0, //Active element [int] - delay: 200, //Animation time [int] - auto: false, //Repeat delay [false||int] - spins: 5, //Number of spins when auto [int] - randomize: null, //Randomize function, must return an integer with the selected position + active: 0, //Active element [Number] + delay: 200, //Animation time [Number] + auto: false, //Repeat delay [false||Number] + spins: 5, //Number of spins when auto [Number] + randomize: null, //Randomize function, must return a number with the selected position complete: null, //Callback function(result) stopHidden: true, //Stops animations if the element isnĀ“t visible on the screen direction: 'up' //Animation direction ['up'||'down'] @@ -88,11 +88,11 @@ function Timer(fn, delay) { var startTime, - self = this, - timer, - _fn = fn, - _args = arguments, - _delay = delay; + self = this, + timer, + _fn = fn, + _args = arguments, + _delay = delay; this.running = false; @@ -244,10 +244,32 @@ } } + /** + * @desc PUBLIC - Custom setTimeout using requestAnimationFrame + * @param function cb - Callback + * @param Number timeout - Timeout delay + */ + SlotMachine.prototype.raf = function(cb, timeout) { + var _raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame, + startTime = new Date().getTime(), + _rafHandler = function(/*timestamp*/){ + var drawStart = new Date().getTime(), + diff = drawStart - startTime; + + if(diff < timeout){ + _raf(_rafHandler); + }else if(typeof cb === 'function'){ + cb(); + } + }; + + _raf(_rafHandler); + }; + /** * @desc PUBLIC - Get element offset top - * @param int index - Element position - * @return int - Negative offset in px + * @param Number index - Element position + * @return Number - Negative offset in px */ SlotMachine.prototype.getTileOffset = function(index) { var offset = 0; @@ -259,7 +281,7 @@ /** * @desc PUBLIC - Get current showing element index - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype.getVisibleTile = function() { var firstTileHeight = this.$tiles.first().height(), @@ -270,7 +292,7 @@ /** * @desc PUBLIC - Changes randomize function - * @param function|int - Set new randomize function + * @param function|Number - Set new randomize function */ SlotMachine.prototype.setRandomize = function(rnd) { if (typeof rnd === 'number') { @@ -285,7 +307,7 @@ /** * @desc PUBLIC - Get random element different than last shown * @param boolean cantBeTheCurrent - true||undefined if cant be choosen the current element, prevents repeat - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype.getRandom = function(cantBeTheCurrent) { var rnd, @@ -299,7 +321,7 @@ /** * @desc PUBLIC - Get random element based on the custom randomize function - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype.getCustom = function() { var choosen; @@ -317,7 +339,7 @@ /** * @desc PRIVATE - Get the previous element (no direction related) - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype._getPrev = function() { var prevIndex = (this.active - 1 < 0) ? (this.$tiles.length - 1) : (this.active - 1); @@ -326,7 +348,7 @@ /** * @desc PRIVATE - Get the next element (no direction related) - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype._getNext = function() { var nextIndex = (this.active + 1 < this.$tiles.length) ? (this.active + 1) : 0; @@ -335,7 +357,7 @@ /** * @desc PUBLIC - Get the previous element dor selected direction - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype.getPrev = function() { return this._direction.selected === 'up' ? this._getPrev() : this._getNext(); @@ -343,7 +365,7 @@ /** * @desc PUBLIC - Get the next element - * @return int - Element index + * @return Number - Element index */ SlotMachine.prototype.getNext = function() { return this._direction.selected === 'up' ? this._getNext() : this._getPrev(); @@ -367,17 +389,15 @@ * @param string||boolean fade - Set fade gradient effect */ SlotMachine.prototype._setAnimationFX = function(FX_SPEED, fade) { - var self = this; - - setTimeout(function() { - self.$tiles.removeClass([FX_FAST, FX_NORMAL, FX_SLOW].join(' ')).addClass(FX_SPEED); + this.raf(function() { + this.$tiles.removeClass([FX_FAST, FX_NORMAL, FX_SLOW].join(' ')).addClass(FX_SPEED); if (fade !== true || FX_SPEED === FX_STOP) { - self.$slot.add(self.$tiles).removeClass(FX_GRADIENT); + this.$slot.add(this.$tiles).removeClass(FX_GRADIENT); } else { - self.$slot.add(self.$tiles).addClass(FX_GRADIENT); + this.$slot.add(this.$tiles).addClass(FX_GRADIENT); } - }, this.settings.delay / 4); + }.bind(this), this.settings.delay / 4); }; /** @@ -389,7 +409,7 @@ /** * @desc PRIVATE - Checks if the machine is on the screen - * @return int - Returns true if machine is on the screen + * @return Number - Returns true if machine is on the screen */ SlotMachine.prototype.isVisible = function() { //Stop animation if element is [above||below] screen, best for performance @@ -401,7 +421,7 @@ /** * @desc PUBLIC - SELECT previous element relative to the current active element - * @return int - Returns result index + * @return Number - Returns result index */ SlotMachine.prototype.prev = function() { this.futureActive = this.getPrev(); @@ -412,7 +432,7 @@ /** * @desc PUBLIC - SELECT next element relative to the current active element - * @return int - Returns result index + * @return Number - Returns result index */ SlotMachine.prototype.next = function() { this.futureActive = this.getNext(); @@ -423,8 +443,8 @@ /** * @desc PUBLIC - Starts shuffling the elements - * @param int repeations - Number of shuffles (undefined to make infinite animation - * @return int - Returns result index + * @param Number repeations - Number of shuffles (undefined to make infinite animation + * @return Number - Returns result index */ SlotMachine.prototype.shuffle = function(spins, onComplete) { var self = this; @@ -491,7 +511,7 @@ /** * @desc PUBLIC - Stop shuffling the elements - * @return int - Returns result index + * @return Number - Returns result index */ SlotMachine.prototype.stop = function(showGradient) { if (!this.isRunning) { @@ -549,9 +569,9 @@ }); //Disable blur - setTimeout(function() { - self._setAnimationFX(FX_STOP, false); - }, delay / 1.75); + this.raf(function() { + this._setAnimationFX(FX_STOP, false); + }.bind(this), delay / 1.75); return this.active; }; @@ -568,7 +588,7 @@ } self.isRunning = true; if (!self.isVisible() && self.settings.stopHidden === true) { - setTimeout(function() { + self.raf(function() { self._timer.reset(); }, 500); } else { diff --git a/dist/jquery.slotmachine.min.js b/dist/jquery.slotmachine.min.js index 90199f5..f350433 100644 --- a/dist/jquery.slotmachine.min.js +++ b/dist/jquery.slotmachine.min.js @@ -1,4 +1,4 @@ -/*! SlotMachine - v2.1.0 - 2015-07-21 +/*! SlotMachine - v2.2.0 - 2015-11-05 * 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.isStopping=!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.$container=this.$tiles.wrapAll('
').parent(),this._maxTop=-this.$container.height(),this._$fakeFirstTile=this.$tiles.last().clone(),this._$fakeLastTile=this.$tiles.first().clone(),this.$container.prepend(this._$fakeFirstTile),this.$container.append(this._$fakeLastTile),this._minTop=-this._$fakeFirstTile.outerHeight(),this._direction={selected:"down"===this.settings.direction?"down":"up",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:{initial:this.getTileOffset(this.active),first:this.getTileOffset(this.$tiles.length),last:0,to:this._minTop,firstToLast:this.getTileOffset(this.$tiles.length),lastToFirst:0},get:function(a){return this[this.selected][a]}},this.$container.css("margin-top",this._direction.get("initial")),this.settings.auto!==!1&&(this.settings.auto===!0?this.shuffle():this.auto())}function g(b,c){var d;return a.data(b[0],"plugin_"+h)?d=a.data(b[0],"plugin_"+h):(d=new f(b,c),a.data(b[0],"plugin_"+h,d)),d}var h="slotMachine",i={active:0,delay:200,auto:!1,spins:5,randomize:null,complete:null,stopHidden:!0,direction:"up"},j="slotMachineBlurFast",k="slotMachineBlurMedium",l="slotMachineBlurSlow",m="slotMachineGradient",n=m;a(c).ready(function(){var b='#slotMachineBlurFilterFast',c='#slotMachineBlurFilterMedium',d='#slotMachineBlurFilterSlow',e='#slotMachineFadeMask';a("body").append("')}),"function"!=typeof a.easing.easeOutBounce&&a.extend(a.easing,{easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?7.5625*d*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}}),f.prototype.getTileOffset=function(a){for(var b=0,c=0;a>c;c++)b+=this.$tiles.eq(c).outerHeight();return-b+this._minTop},f.prototype.getVisibleTile=function(){var a=this.$tiles.first().height(),b=parseInt(this.$container.css("margin-top").replace(/px/,""),10);return Math.abs(Math.round(b/a))-1},f.prototype.setRandomize=function(a){this.settings.randomize="number"==typeof a?function(){return a}:a},f.prototype.getRandom=function(a){var b,c=a||!1;do b=Math.floor(Math.random()*this.$tiles.length);while(c&&b===this.active&&b>=0);return b},f.prototype.getCustom=function(){var a;if(null!==this.settings.randomize&&"function"==typeof this.settings.randomize){var b=this.settings.randomize.apply(this,[this.active]);(0>b||b>=this.$tiles.length)&&(b=0),a=b}else a=this.getRandom();return a},f.prototype._getPrev=function(){var a=this.active-1<0?this.$tiles.length-1:this.active-1;return a},f.prototype._getNext=function(){var a=this.active+1a(b).scrollTop()+a(b).height(),d=a(b).scrollTop()>this.$slot.height()+this.$slot.offset().top;return!c&&!d},f.prototype.prev=function(){return this.futureActive=this.getPrev(),this.isRunning=!0,this.stop(!1),this.futureActive},f.prototype.next=function(){return this.futureActive=this.getNext(),this.isRunning=!0,this.stop(!1),this.futureActive},f.prototype.shuffle=function(a,b){var c=this;b!==d&&(this._oncompleteStack[1]=b),this.isRunning=!0;var e=this.settings.delay;if(null===this.futureActive){var f=this.getCustom();this.futureActive=f}if("number"==typeof a)switch(a){case 1:case 2:this._setAnimationFX(l,!0);break;case 3:case 4:this._setAnimationFX(k,!0),e/=1.5;break;default:this._setAnimationFX(j,!0),e/=2}else this._setAnimationFX(j,!0),e/=2;return this.isVisible()||this.settings.stopHidden!==!0?this.$container.animate({marginTop:this._direction.get("to")},e,"linear",function(){c.$container.css("margin-top",c._direction.get("first")),0>=a-1?c.stop():c.shuffle(a-1)}):(a=0,c.stop()),this.futureActive},f.prototype.stop=function(a){if(this.isRunning){if(this.isStopping)return this.futureActive;var b=this;this.$container.clearQueue().stop(!0,!1),this._setAnimationFX(l,a===d?!0:a),this.isRunning=!0,this.isStopping=!0,this.active=this.getVisibleTile(),this.futureActive>this.active?0===this.active&&this.futureActive===this.$tiles.length-1&&this.$container.css("margin-top",this._direction.get("firstToLast")):this.active===this.$tiles.length-1&&0===this.futureActive&&this.$container.css("margin-top",this._direction.get("lastToFirst")),this.active=this.futureActive;var c=3*this.settings.delay;return this.$container.animate({marginTop:this.getTileOffset(this.active)},c,"easeOutBounce",function(){b.isStopping=!1,b.isRunning=!1,b.futureActive=null,"function"==typeof b._oncompleteStack[0]&&b._oncompleteStack[0].apply(b,[b.active]),"function"==typeof b._oncompleteStack[1]&&b._oncompleteStack[1].apply(b,[b.active])}),setTimeout(function(){b._setAnimationFX(n,!1)},c/1.75),this.active}},f.prototype.auto=function(){var a=this;this._timer=new e(function(){"function"!=typeof a.settings.randomize&&(a.futureActive=a.getNext()),a.isRunning=!0,a.isVisible()||a.settings.stopHidden!==!0?a.shuffle(a.settings.spins,function(){a._timer.reset()}):setTimeout(function(){a._timer.reset()},500)},this.settings.auto)},a.fn[h]=function(b){if(1===this.length)return g(this,b);var c=this;return a.map(c,function(a,d){var e=c.eq(d);return g(e,b)})}}(jQuery,window,document); \ No newline at end of file +!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.isStopping=!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.$container=this.$tiles.wrapAll('
').parent(),this._maxTop=-this.$container.height(),this._$fakeFirstTile=this.$tiles.last().clone(),this._$fakeLastTile=this.$tiles.first().clone(),this.$container.prepend(this._$fakeFirstTile),this.$container.append(this._$fakeLastTile),this._minTop=-this._$fakeFirstTile.outerHeight(),this._direction={selected:"down"===this.settings.direction?"down":"up",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:{initial:this.getTileOffset(this.active),first:this.getTileOffset(this.$tiles.length),last:0,to:this._minTop,firstToLast:this.getTileOffset(this.$tiles.length),lastToFirst:0},get:function(a){return this[this.selected][a]}},this.$container.css("margin-top",this._direction.get("initial")),this.settings.auto!==!1&&(this.settings.auto===!0?this.shuffle():this.auto())}function g(b,c){var d;return a.data(b[0],"plugin_"+h)?d=a.data(b[0],"plugin_"+h):(d=new f(b,c),a.data(b[0],"plugin_"+h,d)),d}var h="slotMachine",i={active:0,delay:200,auto:!1,spins:5,randomize:null,complete:null,stopHidden:!0,direction:"up"},j="slotMachineBlurFast",k="slotMachineBlurMedium",l="slotMachineBlurSlow",m="slotMachineGradient",n=m;a(c).ready(function(){var b='#slotMachineBlurFilterFast',c='#slotMachineBlurFilterMedium',d='#slotMachineBlurFilterSlow',e='#slotMachineFadeMask';a("body").append("')}),"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}}),f.prototype.raf=function(a,c){var d=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame,e=(new Date).getTime(),f=function(){var b=(new Date).getTime(),g=b-e;c>g?d(f):"function"==typeof a&&a()};d(f)},f.prototype.getTileOffset=function(a){for(var b=0,c=0;a>c;c++)b+=this.$tiles.eq(c).outerHeight();return-b+this._minTop},f.prototype.getVisibleTile=function(){var a=this.$tiles.first().height(),b=parseInt(this.$container.css("margin-top").replace(/px/,""),10);return Math.abs(Math.round(b/a))-1},f.prototype.setRandomize=function(a){"number"==typeof a?this.settings.randomize=function(){return a}:this.settings.randomize=a},f.prototype.getRandom=function(a){var b,c=a||!1;do b=Math.floor(Math.random()*this.$tiles.length);while(c&&b===this.active&&b>=0);return b},f.prototype.getCustom=function(){var a;if(null!==this.settings.randomize&&"function"==typeof this.settings.randomize){var b=this.settings.randomize.apply(this,[this.active]);(0>b||b>=this.$tiles.length)&&(b=0),a=b}else a=this.getRandom();return a},f.prototype._getPrev=function(){var a=this.active-1<0?this.$tiles.length-1:this.active-1;return a},f.prototype._getNext=function(){var a=this.active+1a(b).scrollTop()+a(b).height(),d=a(b).scrollTop()>this.$slot.height()+this.$slot.offset().top;return!c&&!d},f.prototype.prev=function(){return this.futureActive=this.getPrev(),this.isRunning=!0,this.stop(!1),this.futureActive},f.prototype.next=function(){return this.futureActive=this.getNext(),this.isRunning=!0,this.stop(!1),this.futureActive},f.prototype.shuffle=function(a,b){var c=this;b!==d&&(this._oncompleteStack[1]=b),this.isRunning=!0;var e=this.settings.delay;if(null===this.futureActive){var f=this.getCustom();this.futureActive=f}if("number"==typeof a)switch(a){case 1:case 2:this._setAnimationFX(l,!0);break;case 3:case 4:this._setAnimationFX(k,!0),e/=1.5;break;default:this._setAnimationFX(j,!0),e/=2}else this._setAnimationFX(j,!0),e/=2;return this.isVisible()||this.settings.stopHidden!==!0?this.$container.animate({marginTop:this._direction.get("to")},e,"linear",function(){c.$container.css("margin-top",c._direction.get("first")),0>=a-1?c.stop():c.shuffle(a-1)}):(a=0,c.stop()),this.futureActive},f.prototype.stop=function(a){if(this.isRunning){if(this.isStopping)return this.futureActive;var b=this;this.$container.clearQueue().stop(!0,!1),this._setAnimationFX(l,a===d?!0:a),this.isRunning=!0,this.isStopping=!0,this.active=this.getVisibleTile(),this.futureActive>this.active?0===this.active&&this.futureActive===this.$tiles.length-1&&this.$container.css("margin-top",this._direction.get("firstToLast")):this.active===this.$tiles.length-1&&0===this.futureActive&&this.$container.css("margin-top",this._direction.get("lastToFirst")),this.active=this.futureActive;var c=3*this.settings.delay;return this.$container.animate({marginTop:this.getTileOffset(this.active)},c,"easeOutBounce",function(){b.isStopping=!1,b.isRunning=!1,b.futureActive=null,"function"==typeof b._oncompleteStack[0]&&b._oncompleteStack[0].apply(b,[b.active]),"function"==typeof b._oncompleteStack[1]&&b._oncompleteStack[1].apply(b,[b.active])}),this.raf(function(){this._setAnimationFX(n,!1)}.bind(this),c/1.75),this.active}},f.prototype.auto=function(){var a=this;this._timer=new e(function(){"function"!=typeof a.settings.randomize&&(a.futureActive=a.getNext()),a.isRunning=!0,a.isVisible()||a.settings.stopHidden!==!0?a.shuffle(a.settings.spins,function(){a._timer.reset()}):a.raf(function(){a._timer.reset()},500)},this.settings.auto)},a.fn[h]=function(b){if(1===this.length)return g(this,b);var c=this;return a.map(c,function(a,d){var e=c.eq(d);return g(e,b)})}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 2447617..0defe34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-slotmachine", - "version": "2.1.0", + "version": "2.2.0", "engines": { "node": ">= 0.8.0" }, diff --git a/slotmachine.jquery.json b/slotmachine.jquery.json index 55e30d7..d3ebe42 100644 --- a/slotmachine.jquery.json +++ b/slotmachine.jquery.json @@ -11,7 +11,7 @@ "winning", "machine" ], - "version": "2.1.0", + "version": "2.2.0", "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 8dcc22a..55979f7 100644 --- a/src/jquery.slotmachine.js +++ b/src/jquery.slotmachine.js @@ -256,7 +256,7 @@ SlotMachine.prototype.raf = function(cb, timeout) { var _raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame, startTime = new Date().getTime(), - _rafHandler = function(timestamp){ + _rafHandler = function(/*timestamp*/){ var drawStart = new Date().getTime(), diff = drawStart - startTime;