Created
January 11, 2013 14:26
-
-
Save Lasha/4511021 to your computer and use it in GitHub Desktop.
Self invoking function after initial trigger, utilizing setTimeouts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var activeCounter = 0, | |
$acitivityMsgs = $('.progress-bar').find('.message'), | |
$activeMsg = $acitivityMsgs.filter('.active'), | |
totalMessages = $acitivityMsgs.length, | |
activityTimer = 5000; | |
function activityAdvance(){ | |
if (activeCounter < totalMessages-1){ | |
$activeMsg = $activeMsg.fadeOut('slow').removeClass('active').next().fadeIn('fast').addClass('active'); | |
// activeCounter = $activeMsg.index('.message') + 1; | |
activeCounter += 1; | |
var timeout = setTimeout(function(){ activityAdvance(); clearTimeout(timeout); }, activityTimer); | |
} else { | |
$activeMsg.fadeOut('slow').removeClass('active') | |
$activeMsg = $acitivityMsgs.eq(0).fadeIn('fast').addClass('active'); | |
activeCounter = 0; | |
var timeout = setTimeout(function(){ activityAdvance(); clearTimeout(timeout); }, activityTimer); | |
} | |
} | |
setTimeout(function(){ | |
activityAdvance(); | |
},activityTimer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment