forked from mateagar/imageRotator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageRotator.min.js
1 lines (1 loc) · 1.06 KB
/
imageRotator.min.js
1
(function(e){e.fn.imageRotator=function(t){function a(e){if(s>=0){var t=r[s];t.fadeOut(e)}var n=s+1;if(s>=r.length-1){n=0}var i=r[n];i.fadeIn(e,function(){s=n})}if(this.getImages){return this}var n=e.extend({},e.fn.imageRotator.defaults,t);if(n.imageTime<100){n.imageTime=100}var r=null;var i=null;var s=0;var o=null;var u=null;this.css("position","relative");this.getOptions=function(){return n};this.getImages=function(){return r};this.getCurrentIndex=function(){return s};this.setCurrentIndex=function(e){i.hide();if(e>=r.length){e=r.length-1}if(e>=0){r[e].show()}s=e};this.start=function(){if(o){}else if(r.length>1){o=setInterval(function(){var e=n.imageTime-n.fadeTime;if(e<0){a(n.imageTime-90)}else{u=setTimeout(function(){u=null;a(n.fadeTime)},e)}},n.imageTime)}};this.stop=function(){if(o){if(u){clearTimeout(u);u=null}clearInterval(o);o=null;if(s>=0){r[s].show()}}};this.refresh=function(){r=[];i=this.children("img");i.each(function(t){r.push(e(this))});this.setCurrentIndex(s)};this.refresh();return this};e.fn.imageRotator.defaults={imageTime:1e3,fadeTime:500}})(jQuery)