nikki/liteAccordion — Issue #29: Accordion tries to switch, even if it's invisible
Author: MadCat81
Created: 2011-11-15 01:04:28+00:00
State: open

Hey Nikki,

I just found some info in my debugger, that your nice liteAccordion was trying to get the $groups variable and change to the next tab, even if the whole accordion was not visible.
My litteAccordion was toggeled within a

and wasn't there for the eye.
So the CSS was set to display: none.
That's why the PLAY method of your liteAccordion messed up and threw errors.

Here is a small an simple bugfix for this issue (showing only the utils.play() function I changed):

play : function(slideIndex) {
var getNext = utils.nextSlide((slideIndex) ? slideIndex : ''), // create closure
start = function() {
if($header.is(':visible')) {
$header.eq(getNext()).click();
}
};
utils.playing = setInterval(start, settings.cycleSpeed);
},

I just added the if($header.is('visible')) { }.
So the interval will be kept and as long as the liteaccordion is not shown, it'll not try to click/change to the next tab.

Perhaps one could blow this up with a new option, like "autoStopOnHide" which will automatically stop the sliding ( clearInterval() ) during the liteAccordion is hidden.
But you'll have to manually allow to start the sliding afterwards again, by making the play method able to be used from your external source code, or by triggering a mouse hover and leave perhaps (this is only a workaround ;-) )

Regards
MaD