diff --git a/README.md b/README.md index a675017..ae09ef3 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ var foo = new Sprite(..., frames); ### play([options]) Starts the animation. -- `options` (Object) - Override any of the options set previously. See Options. +- `options` (Object) - Override any of the options set previously. [See Options](#options). ```javascript var foo = new Sprite(..., ..., {fps: 12, reverse: true}); @@ -71,7 +71,7 @@ Stops the animation, optionally on a specific frame. - `options` (Object) - `frame` (Number) - Frame number to stop on - `animated` (Boolean) - If stopping should be animated - - `callback` (Function) - Called on completion of `stop` + - `onComplete` (Function) - Called on completion of `stop` ### frame([value]) Getter/Setter for frame. diff --git a/sprite.js b/sprite.js index a74a94d..42cfa9f 100644 --- a/sprite.js +++ b/sprite.js @@ -255,7 +255,7 @@ * @param {Object} options - Optional options * {Number} frame - Frame to stop on * {Boolean} animated - Whether to animate to the stopping frame - * {Function} callback - Callback once Sprite is stopped + * {Function} onComplete - Callback once Sprite is stopped * @returns {Sprite} */ this.stop = function(options){ @@ -263,18 +263,18 @@ if (!isPlaying) {return this;} - options = mergeObjects({callback: fun, frame: currentFrame, animated: false}, options); + options = mergeObjects({onComplete: fun, frame: currentFrame, animated: false}, options); options.frame = isNumeric(options.frame) ? options.frame : currentFrame; clearRequestInterval(animationTick); isPlaying = false; if (!options.animated) { this.frame(options.frame); - options.callback.call(this); + options.onComplete.call(this); } else { this.play({reverse: currentOptions.reverse, fps: currentOptions.fps, onFrame: function(currentFrame){ if (options.frame === currentFrame) { - that.stop({callback: options.callback}); + that.stop({onComplete: options.onComplete}); } }}); } diff --git a/sprite.min.js b/sprite.min.js index 078faea..bcdf4ad 100644 --- a/sprite.min.js +++ b/sprite.min.js @@ -5,4 +5,4 @@ * MIT license * @license */ -!function(a){"use strict";var b="1.0.1",c=function(){},d=function(a,b){for(var c=[],d=0;b>d;d+=1)c.push([d*a.width,0,a.width,a.height]);return c},e=function(){var a,b,c,d="object"==typeof arguments[0]?arguments[0]:{},e=arguments.length;for(a=0;e>a;a+=1)if(b=arguments[a],null!==b)for(c in b)d[c]=b[c];return d},f=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)};!function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c=b&&(a.call(),d=(new Date).getTime())}if(!(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame&&window.mozCancelRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame))return window.setInterval(a,b);var d=(new Date).getTime(),e={};return e.value=requestAnimationFrame(c),e},i=function(a){window.cancelAnimationFrame?window.cancelAnimationFrame(a.value):window.webkitCancelAnimationFrame?window.webkitCancelAnimationFrame(a.value):window.webkitCancelRequestAnimationFrame?window.webkitCancelRequestAnimationFrame(a.value):window.mozCancelRequestAnimationFrame?window.mozCancelRequestAnimationFrame(a.value):window.oCancelRequestAnimationFrame?window.oCancelRequestAnimationFrame(a.value):window.msCancelRequestAnimationFrame?window.msCancelRequestAnimationFrame(a.value):window.clearInterval(a)},j=function(a,b,k){var l,m,n,o,p=!1,q=0;this.el=a,this.options=e({},j.defaults,k),this.numFrames=b.length?b.length:Math.floor(k.imageWidth/b.width)*Math.floor(k.imageHeight/b.height),m=g(b)?b:d(b,this.numFrames),l=e({},this.options);var r=function(a){this.el.style.backgroundPosition=-a[0]+"px "+-a[1]+"px"};this.isPlaying=function(){return p},this.frame=function(a){return f(a)&&q!==a&&(q=ad;d+=1)c.push([d*a.width,0,a.width,a.height]);return c},e=function(){var a,b,c,d="object"==typeof arguments[0]?arguments[0]:{},e=arguments.length;for(a=0;e>a;a+=1)if(b=arguments[a],null!==b)for(c in b)d[c]=b[c];return d},f=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)};!function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c=b&&(a.call(),d=(new Date).getTime())}if(!(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame&&window.mozCancelRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame))return window.setInterval(a,b);var d=(new Date).getTime(),e={};return e.value=requestAnimationFrame(c),e},i=function(a){window.cancelAnimationFrame?window.cancelAnimationFrame(a.value):window.webkitCancelAnimationFrame?window.webkitCancelAnimationFrame(a.value):window.webkitCancelRequestAnimationFrame?window.webkitCancelRequestAnimationFrame(a.value):window.mozCancelRequestAnimationFrame?window.mozCancelRequestAnimationFrame(a.value):window.oCancelRequestAnimationFrame?window.oCancelRequestAnimationFrame(a.value):window.msCancelRequestAnimationFrame?window.msCancelRequestAnimationFrame(a.value):window.clearInterval(a)},j=function(a,b,k){var l,m,n,o,p=!1,q=0;this.el=a,this.options=e({},j.defaults,k),this.numFrames=b.length?b.length:Math.floor(k.imageWidth/b.width)*Math.floor(k.imageHeight/b.height),m=g(b)?b:d(b,this.numFrames),l=e({},this.options);var r=function(a){this.el.style.backgroundPosition=-a[0]+"px "+-a[1]+"px"};this.isPlaying=function(){return p},this.frame=function(a){return f(a)&&q!==a&&(q=a