diff --git a/jquery.motio.js b/jquery.motio.js index f9c9fe1..9fd0c04 100644 --- a/jquery.motio.js +++ b/jquery.motio.js @@ -1,5 +1,5 @@ /*! - * jQuery Motio v1.0.0 + * jQuery Motio v1.0.1 * https://github.com/Darsain/motio * * Licensed under the MIT license. @@ -378,7 +378,7 @@ // Update background position setPos( newpos ); - }; + } /** @@ -477,11 +477,11 @@ $.fn[pluginName] = function( options, returnInstance ){ var method = false, - instances = [], - methodArgs; + methodArgs, + instances = []; // Basic attributes logic - if( options && !$.isPlainObject( options ) ){ + if( typeof options !== 'undefined' && !$.isPlainObject( options ) ){ method = options === false ? 'destroy' : options; methodArgs = arguments; Array.prototype.shift.call( methodArgs ); diff --git a/jquery.motio.min.js b/jquery.motio.min.js index f7daec6..e3c3027 100644 --- a/jquery.motio.min.js +++ b/jquery.motio.min.js @@ -1,6 +1,6 @@ -(function(d){function z(g,u){function b(a,b){i&&i[a]&&i[a].fireWith(g,b);h.trigger(r+":"+a,b)}function m(){var a;q=setTimeout(function(){s(m)},1E3/c.fps);if(e)n[o]+=c.speed/c.fps,0c.bgSize&&(n[o]%=c.bgSize),a=n;else{switch(l){case "toStart":0>=--f&&(l=f=0,j.pause(),b("start"));break;case "toEnd":++f>=k.length-1&&(l=0,f=k.length-1,j.pause(),b("end"));break;case "to":ft&&f--;f===t&&(b("to",[g]),j.pause());break;default:++f>=k.length&&(f=0)}a=f}p(a)}function p(a){var x= -!e&&!isNaN(parseFloat(a))&&isFinite(a)?k[a]:"object"===typeof a?a.x+"px "+a.y+"px":!1;x&&(g.style.backgroundPosition=x,e||(f=a),b("frame",e?[a[o],c.bgSize]:[a,k.length]))}var h,c,e,q,y,k,f,v,n,o,l,t,j=this,i=!d.Callbacks?!1:{};this.pause=function(){q&&(q=clearTimeout(q),b("pause"))};this.play=function(){q||(m(),b("play"))};this.toggle=function(){b("toggle");j[q?"pause":"play"]()};this.set=function(a,b){-1!==d.inArray(a,["speed","fps"])&&(c[a]=b)};this.toStart=function(a){e||(a||0===f?(l=!1,b("start"), -j.pause(),p(0)):(l="toStart",j.play()))};this.toEnd=function(a){e||(a||f===k.length-1?(l=0,b("end"),j.pause(),p(k.length-1)):(l="toEnd",j.play()))};this.to=function(a,c){if(!e&&!(isNaN(parseFloat(a))||!isFinite(a)||0>a&&a>=k.length))c||a===f?(l=0,b("to",[a]),j.pause(),p(a)):(l="to",t=a,j.play())};this.on=function(a,b){i&&b&&(i[a]||(i[a]=d.Callbacks("unique")),i[a].add(b))};this.off=function(a,b){i&&i[a]&&(b?i[a].remove(b):i[a].empty())};this.destroy=function(){j.pause();h.css("backgroundPosition", -v);d.removeData(g,w)};(function(){h=d(g);c=d.extend({},d.fn[r].defaults,u);e=!c.frames;q=0;y=h[c.vertical?"innerHeight":"innerWidth"]();o=c.vertical?"y":"x";v=h.css("backgroundPosition")||h.css("backgroundPositionX")+" "+h.css("backgroundPositionY");var a=v.replace(/left|top/g,0).split(" ");n={x:parseInt(a[0],10),y:parseInt(a[1],10)};if(!e){a=n;k=[];for(var b=0;bc.bgSize&&(n[o]%=c.bgSize),a=n;else{switch(k){case "toStart":0>=--f&&(k=f=0,i.pause(),b("start"));break;case "toEnd":++f>=j.length-1&&(k=0,f=j.length-1,i.pause(),b("end"));break;case "to":fw&&f--;f===w&&(b("to",[g]),i.pause());break;default:++f>=j.length&&(f=0)}a=f}l(a)}function l(a){var d= +!e&&!isNaN(parseFloat(a))&&isFinite(a)?j[a]:"object"===typeof a?a.x+"px "+a.y+"px":!1;d&&(g.style.backgroundPosition=d,e||(f=a),b("frame",e?[a[o],c.bgSize]:[a,j.length]))}var m,c,e,r,t,j,f,x,n,o,k,w,i=this,h=!d.Callbacks?!1:{};this.pause=function(){r&&(r=clearTimeout(r),b("pause"))};this.play=function(){r||(q(),b("play"))};this.toggle=function(){b("toggle");i[r?"pause":"play"]()};this.set=function(a,b){-1!==d.inArray(a,["speed","fps"])&&(c[a]=b)};this.toStart=function(a){e||(a||0===f?(k=!1,b("start"), +i.pause(),l(0)):(k="toStart",i.play()))};this.toEnd=function(a){e||(a||f===j.length-1?(k=0,b("end"),i.pause(),l(j.length-1)):(k="toEnd",i.play()))};this.to=function(a,c){if(!e&&!(isNaN(parseFloat(a))||!isFinite(a)||0>a&&a>=j.length))c||a===f?(k=0,b("to",[a]),i.pause(),l(a)):(k="to",w=a,i.play())};this.on=function(a,b){h&&b&&(h[a]||(h[a]=d.Callbacks("unique")),h[a].add(b))};this.off=function(a,b){h&&h[a]&&(b?h[a].remove(b):h[a].empty())};this.destroy=function(){i.pause();m.css("backgroundPosition", +x);d.removeData(g,y)};m=d(g);c=d.extend({},d.fn[u].defaults,p);e=!c.frames;r=0;t=m[c.vertical?"innerHeight":"innerWidth"]();o=c.vertical?"y":"x";x=m.css("backgroundPosition")||m.css("backgroundPositionX")+" "+m.css("backgroundPositionY");var s=x.replace(/left|top/g,0).split(" ");n={x:parseInt(s[0],10),y:parseInt(s[1],10)};if(!e){s=n;j=[];for(var z=0;z