Hello, I've set up an accordion on a web page, now I would like it to
scroll automatically every 8 seconds, so I put up a little function
calleb by a setInterval. Here is the code I've used:
var numAcc = $('#highlights h2').length;
//console.log(numAcc);
var currentAcc = 0;
var time = 8000;
//console.log($('#highlights div.item:last'));
$('#highlights div.item:last').addClass('last');
$('#highlights').accordion({
header: 'h2',
change: function(event, ui) {
clearInterval(autoAccordion);
currentAcc = ui.newHeader.attr('id').replace(/[^\d]/g,'');
//console.log('1: ' + currentAcc);
autoAccordion = setInterval('autoScroll()',time);
ui.newHeader.blur();
}
});
function autoScroll(){
var nextAcc = (currentAcc == numAcc) ? 0 : currentAcc++;
//console.log('2: Cur=' + currentAcc + '; Next='+nextAcc);
$('#highlights').accordion('activate',nextAcc);
}
autoAccordion = setInterval('autoScroll()',time);
Where #highlights is the container of my accordion. Everything works
great but there's a little but annoying problem: when the function
autoScroll is called the activated content is focused, so if I'm
watching another part of the page I see the page scroll up or down by
itself, and that's ugly, isn't it?
Do you have any hint about it?
Thank you,
Mitch.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---