diff --git a/jquery.jshowoff.js b/jquery.jshowoff.js index 90dc8a2..3147fe0 100644 --- a/jquery.jshowoff.js +++ b/jquery.jshowoff.js @@ -159,8 +159,10 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000] // start slide rotation on specified interval function play(src) { if(!isBusy()){ - counter++; - transitionTo(gallery,counter); + if(src!='hover') { + counter++; + transitionTo(gallery,counter); + } if(src=='hover' || !isPlaying()) { timer = setInterval(function(){ play(); },config.speed); } diff --git a/jquery.jshowoff.min.js b/jquery.jshowoff.min.js index ac7a965..b23dcfb 100644 --- a/jquery.jshowoff.min.js +++ b/jquery.jshowoff.min.js @@ -7,9 +7,4 @@ Website: http://ekallevig.com/jshowoff License: Dual licensed under the MIT and GPL licenses. */ - -(function($){$.fn.jshowoff=function(settings){var config={animatePause:true,autoPlay:true,changeSpeed:600,controls:true,controlText:{play:'Play',pause:'Pause',next:'Next',previous:'Previous'},effect:'fade',hoverPause:true,links:true,speed:3000};if(settings)$.extend(true,config,settings);if(config.speed<(config.changeSpeed+20)){alert('jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren\'t always right on time.');return this;};this.each(function(i){var $cont=$(this);var gallery=$(this).children().remove();var timer='';var counter=0;var preloadedImg=[];var howManyInstances=$('.jshowoff').length+1;var uniqueClass='jshowoff-'+howManyInstances;var cssClass=config.cssClass!=undefined?config.cssClass:'';$cont.css('position','relative').wrap('
');var $wrap=$('.'+uniqueClass);$wrap.css('position','relative').addClass(cssClass);$(gallery[0]).clone().appendTo($cont);preloadImg();if(config.controls){addControls();if(config.autoPlay==false){$('.'+uniqueClass+'-play').addClass(uniqueClass+'-paused jshowoff-paused').text(config.controlText.play);};};if(config.links){addSlideLinks();$('.'+uniqueClass+'-slidelinks a').eq(0).addClass(uniqueClass+'-active jshowoff-active');};if(config.hoverPause){$cont.hover(function(){if(isPlaying())pause('hover');},function(){if(isPlaying())play('hover');});};if(config.autoPlay&&gallery.length>1){timer=setInterval(function(){play();},config.speed);};if(gallery.length<1){$('.'+uniqueClass).append('

For jShowOff to work, the container element must have child elements.

');};function transitionTo(gallery,index){var oldCounter=counter;if((counter>=gallery.length)||(index>=gallery.length)){counter=0;var e2b=true;} -else if((counter<0)||(index<0)){counter=gallery.length-1;var b2e=true;} -else{counter=index;} -if(config.effect=='slideLeft'){var newSlideDir,oldSlideDir;function slideDir(dir){newSlideDir=dir=='right'?'left':'right';oldSlideDir=dir=='left'?'left':'right';};counter>=oldCounter?slideDir('left'):slideDir('right');$(gallery[counter]).clone().appendTo($cont).slideIt({direction:newSlideDir,changeSpeed:config.changeSpeed});if($cont.children().length>1){$cont.children().eq(0).css('position','absolute').slideIt({direction:oldSlideDir,showHide:'hide',changeSpeed:config.changeSpeed},function(){$(this).remove();});};}else if(config.effect=='fade'){$(gallery[counter]).clone().appendTo($cont).hide().fadeIn(config.changeSpeed,function(){if($.browser.msie)this.style.removeAttribute('filter');});if($cont.children().length>1){$cont.children().eq(0).css('position','absolute').fadeOut(config.changeSpeed,function(){$(this).remove();});};}else if(config.effect=='none'){$(gallery[counter]).clone().appendTo($cont);if($cont.children().length>1){$cont.children().eq(0).css('position','absolute').remove();};};if(config.links){$('.'+uniqueClass+'-active').removeClass(uniqueClass+'-active jshowoff-active');$('.'+uniqueClass+'-slidelinks a').eq(counter).addClass(uniqueClass+'-active jshowoff-active');};};function isPlaying(){return $('.'+uniqueClass+'-play').hasClass('jshowoff-paused')?false:true;};function play(src){if(!isBusy()){counter++;transitionTo(gallery,counter);if(src=='hover'||!isPlaying()){timer=setInterval(function(){play();},config.speed);} -if(!isPlaying()){$('.'+uniqueClass+'-play').text(config.controlText.pause).removeClass('jshowoff-paused '+uniqueClass+'-paused');}};};function pause(src){clearInterval(timer);if(!src||src=='playBtn')$('.'+uniqueClass+'-play').text(config.controlText.play).addClass('jshowoff-paused '+uniqueClass+'-paused');if(config.animatePause&&src=='playBtn'){$('

'+config.controlText.pause+'

').css({fontSize:'62%',textAlign:'center',position:'absolute',top:'40%',lineHeight:'100%',width:'100%'}).appendTo($wrap).addClass(uniqueClass+'pauseText').animate({fontSize:'600%',top:'30%',opacity:0},{duration:500,complete:function(){$(this).remove();}});}};function next(){goToAndPause(counter+1);};function previous(){goToAndPause(counter-1);};function isBusy(){return $cont.children().length>1?true:false;};function goToAndPause(index){$cont.children().stop(true,true);if((counter!=index)||((counter==index)&&isBusy())){if(isBusy())$cont.children().eq(0).remove();transitionTo(gallery,index);pause();};};function preloadImg(){$(gallery).each(function(i){$(this).find('img').each(function(i){preloadedImg[i]=$('').attr('src',$(this).attr('src'));});});};function addControls(){$wrap.append('

'+config.controlText.pause+' '+config.controlText.previous+' '+config.controlText.next+'

');$('.'+uniqueClass+'-controls a').each(function(){if($(this).hasClass('jshowoff-play'))$(this).click(function(){isPlaying()?pause('playBtn'):play();return false;});if($(this).hasClass('jshowoff-prev'))$(this).click(function(){previous();return false;});if($(this).hasClass('jshowoff-next'))$(this).click(function(){next();return false;});});};function addSlideLinks(){$wrap.append('');$.each(gallery,function(i,val){var linktext=$(this).attr('title')!=''?$(this).attr('title'):i+1;$(''+linktext+'').bind('click',{index:i},function(e){goToAndPause(e.data.index);return false;}).appendTo('.'+uniqueClass+'-slidelinks');});};});return this;};})(jQuery);(function($){$.fn.slideIt=function(settings,callback){var config={direction:'left',showHide:'show',changeSpeed:600};if(settings)$.extend(config,settings);this.each(function(i){$(this).css({left:'auto',right:'auto',top:'auto',bottom:'auto'});var measurement=(config.direction=='left')||(config.direction=='right')?$(this).outerWidth():$(this).outerHeight();var startStyle={};startStyle['position']=$(this).css('position')=='static'?'relative':$(this).css('position');startStyle[config.direction]=(config.showHide=='show')?'-'+measurement+'px':0;var endStyle={};endStyle[config.direction]=config.showHide=='show'?0:'-'+measurement+'px';$(this).css(startStyle).animate(endStyle,config.changeSpeed,callback);});return this;};})(jQuery); \ No newline at end of file +(function(a){a.fn.jshowoff=function(c){var b={animatePause:true,autoPlay:true,changeSpeed:600,controls:true,controlText:{play:"Play",pause:"Pause",next:"Next",previous:"Previous"},effect:"fade",hoverPause:true,links:true,speed:3000};if(c){a.extend(true,b,c)}if(b.speed<(b.changeSpeed+20)){alert("jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren't always right on time.");return this}this.each(function(t){var l=a(this);var d=a(this).children().remove();var p="";var o=0;var s=[];var j=a(".jshowoff").length+1;var m="jshowoff-"+j;var n=b.cssClass!=undefined?b.cssClass:"";l.css("position","relative").wrap('
');var q=a("."+m);q.css("position","relative").addClass(n);a(d[0]).clone().appendTo(l);k();if(b.controls){v();if(b.autoPlay==false){a("."+m+"-play").addClass(m+"-paused jshowoff-paused").text(b.controlText.play)}}if(b.links){u();a("."+m+"-slidelinks a").eq(0).addClass(m+"-active jshowoff-active")}if(b.hoverPause){l.hover(function(){if(g()){h("hover")}},function(){if(g()){x("hover")}})}if(b.autoPlay&&d.length>1){p=setInterval(function(){x()},b.speed)}if(d.length<1){a("."+m).append("

For jShowOff to work, the container element must have child elements.

")}function e(z,B){var i=o;if((o>=z.length)||(B>=z.length)){o=0;var D=true}else{if((o<0)||(B<0)){o=z.length-1;var A=true}else{o=B}}if(b.effect=="slideLeft"){var E,F;function C(G){E=G=="right"?"left":"right";F=G=="left"?"left":"right"}o>=i?C("left"):C("right");a(z[o]).clone().appendTo(l).slideIt({direction:E,changeSpeed:b.changeSpeed});if(l.children().length>1){l.children().eq(0).css("position","absolute").slideIt({direction:F,showHide:"hide",changeSpeed:b.changeSpeed},function(){a(this).remove()})}}else{if(b.effect=="fade"){a(z[o]).clone().appendTo(l).hide().fadeIn(b.changeSpeed,function(){if(a.browser.msie){this.style.removeAttribute("filter")}});if(l.children().length>1){l.children().eq(0).css("position","absolute").fadeOut(b.changeSpeed,function(){a(this).remove()})}}else{if(b.effect=="none"){a(z[o]).clone().appendTo(l);if(l.children().length>1){l.children().eq(0).css("position","absolute").remove()}}}}if(b.links){a("."+m+"-active").removeClass(m+"-active jshowoff-active");a("."+m+"-slidelinks a").eq(o).addClass(m+"-active jshowoff-active")}}function g(){return a("."+m+"-play").hasClass("jshowoff-paused")?false:true}function x(i){if(!y()){if(i!="hover"){o++;e(d,o)}if(i=="hover"||!g()){p=setInterval(function(){x()},b.speed)}if(!g()){a("."+m+"-play").text(b.controlText.pause).removeClass("jshowoff-paused "+m+"-paused")}}}function h(i){clearInterval(p);if(!i||i=="playBtn"){a("."+m+"-play").text(b.controlText.play).addClass("jshowoff-paused "+m+"-paused")}if(b.animatePause&&i=="playBtn"){a('

'+b.controlText.pause+"

").css({fontSize:"62%",textAlign:"center",position:"absolute",top:"40%",lineHeight:"100%",width:"100%"}).appendTo(q).addClass(m+"pauseText").animate({fontSize:"600%",top:"30%",opacity:0},{duration:500,complete:function(){a(this).remove()}})}}function r(){w(o+1)}function f(){w(o-1)}function y(){return l.children().length>1?true:false}function w(i){l.children().stop(true,true);if((o!=i)||((o==i)&&y())){if(y()){l.children().eq(0).remove()}e(d,i);h()}}function k(){a(d).each(function(z){a(this).find("img").each(function(A){s[A]=a("").attr("src",a(this).attr("src"))})})}function v(){q.append('

'+b.controlText.pause+' '+b.controlText.previous+' '+b.controlText.next+"

");a("."+m+"-controls a").each(function(){if(a(this).hasClass("jshowoff-play")){a(this).click(function(){g()?h("playBtn"):x();return false})}if(a(this).hasClass("jshowoff-prev")){a(this).click(function(){f();return false})}if(a(this).hasClass("jshowoff-next")){a(this).click(function(){r();return false})}})}function u(){q.append('');a.each(d,function(z,B){var A=a(this).attr("title")!=""?a(this).attr("title"):z+1;a(''+A+"").bind("click",{index:z},function(i){w(i.data.index);return false}).appendTo("."+m+"-slidelinks")})}});return this}})(jQuery);(function(a){a.fn.slideIt=function(c,d){var b={direction:"left",showHide:"show",changeSpeed:600};if(c){a.extend(b,c)}this.each(function(f){a(this).css({left:"auto",right:"auto",top:"auto",bottom:"auto"});var g=(b.direction=="left")||(b.direction=="right")?a(this).outerWidth():a(this).outerHeight();var e={};e.position=a(this).css("position")=="static"?"relative":a(this).css("position");e[b.direction]=(b.showHide=="show")?"-"+g+"px":0;var h={};h[b.direction]=b.showHide=="show"?0:"-"+g+"px";a(this).css(e).animate(h,b.changeSpeed,d)});return this}})(jQuery);