Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions jquery.jshowoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ effect : transition effect [string: 'fade', 'slideLeft' or 'none', defaults to
hoverPause : whether to pause on hover [boolean, defaults to true]
links : whether to create & display numeric links to each slide [boolean, defaults to true]
speed : time each slide is shown [integer, milliseconds, defaults to 3000]
afterChange : called after a slide has changed [function, function() {}]

*/

Expand All @@ -41,17 +42,20 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000]
effect : 'fade',
hoverPause : true,
links : true,
speed : 3000
speed : 3000,
afterChange : $.noop
};

// merge default global variables with custom variables, modifying 'config'
if (settings) $.extend(true, config, settings);
if (settings) {
$.extend(true, config, settings);
}

// make sure speed is at least 20ms longer than changeSpeed
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;
};
}

// create slideshow for each matching element invoked by .jshowoff()
this.each(function(i) {
Expand All @@ -64,7 +68,7 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000]
var preloadedImg = [];
var howManyInstances = $('.jshowoff').length+1;
var uniqueClass = 'jshowoff-'+howManyInstances;
var cssClass = config.cssClass != undefined ? config.cssClass : '';
var cssClass = config.cssClass !== undefined ? config.cssClass : '';


// set up wrapper
Expand All @@ -81,7 +85,7 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000]
// add controls
if(config.controls){
addControls();
if(config.autoPlay==false){
if(config.autoPlay === false){
$('.'+uniqueClass+'-play').addClass(uniqueClass+'-paused jshowoff-paused').text(config.controlText.play);
};
};
Expand Down Expand Up @@ -123,24 +127,25 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000]
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();});
$cont.children().eq(0).css('position','absolute').slideIt({direction:oldSlideDir,showHide:'hide',changeSpeed:config.changeSpeed},function(){$(this).remove();config.afterChange(counter)});
};
} 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();});
$cont.children().eq(0).css('position','absolute').fadeOut(config.changeSpeed,function(){$(this).remove();config.afterChange(counter);});
};
} else if (config.effect=='none') {
$(gallery[counter]).clone().appendTo($cont);
if($cont.children().length>1){
$cont.children().eq(0).css('position','absolute').remove();
config.afterChange(counter);
};
};

Expand Down Expand Up @@ -280,4 +285,4 @@ speed : time each slide is shown [integer, milliseconds, defaults to 3000]
};

// end closure
})(jQuery);
})(jQuery);