Skip to content

Instantly share code, notes, and snippets.

@simonjpartridge
Created September 1, 2015 14:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonjpartridge/77159f1f2feaeb8d6b23 to your computer and use it in GitHub Desktop.
Save simonjpartridge/77159f1f2feaeb8d6b23 to your computer and use it in GitHub Desktop.
Small script to add progress bar to cycle2 http://jquery.malsup.com/cycle2/ slideshows, supports multiple slideshows on one page
//Author Simon Partridge http://simonjpartridge.co.uk
//Supports multiple slideshows on one page
//Simply add <div class="cycle-progress"></div> within the cycle-slideshow div and style as you wish
$('.cycle-slideshow').each(function(){
var slideshow = $(this);
var progress = $(this).children('.cycle-progress');
slideshow.on( 'cycle-initialized cycle-before', function( e, opts ) {
progress.stop(true).css( 'width', 0 );
});
slideshow.on( 'cycle-initialized cycle-after', function( e, opts ) {
if ( ! slideshow.is('.cycle-paused') )
progress.animate({ width: '100%' }, opts.timeout, 'linear' );
});
slideshow.on( 'cycle-paused', function( e, opts ) {
progress.stop();
});
slideshow.on( 'cycle-resumed', function( e, opts, timeoutRemaining ) {
progress.animate({ width: '100%' }, timeoutRemaining, 'linear' );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment