zAccordion
zAccordion is a horizontal accordion plugin for jQuery. Download it now.
The latest version of zAccordion is Version 2.1.0.
Examples
- A Barebones Example
- An Advanced Example - Demonstrates animationStart, animationComplete, and startingSlide
- Another Advanced Example
- Fade in the Accordion - Demonstrates buildComplete
- A Responsive Example using Media Queries
Download
jQuery zAccordion comes with the JavaScript files (minimized and non-minimized) as well as some examples.
Release Notes
As of the new version 2.1.0, zAccordion will not be tested in Internet Explorer 6 or Internet Explorer 7. zAccordion is supported in Internet Explorer 8 and the latest builds of Firefox, Chrome, and Safari.
Version 2.1.0 — September 26, 2012
- Added a destroyComplete option that is available after the accordion is destroyed.
- Renamed afterBuild to buildComplete to align with naming conventions.
- Fixed a small display issue with list-items inheriting a text-indent property.
- Suppressed zAccordion specific errors. Errors can be enabled with errors: true.
Version 2.0.0 — September 18, 2011
As of the new version 2.0.0, zAccordion's options have changed. zAccordion was also rebuilt to follow jQuery's best practices in Plugin Authoring.
- New plugin structure.
- Cleaned up non-minimized code to confine to JSLint standards.
- Added support for percentages when defining height and width.
- Fixed an issue with the pause option stopping accordion even when set to false.
- Many smaller bug fixes and optimizations as well as error checking.
Version 1.1.2 — June 12, 2011
- Added a function named afterBuild that will fire once the accordion is ready.
Version 1.1.1 — May 17, 2011
- Fixed an issue with events building up.
- Fixed an issue with slides automatically rotating after being triggered even if auto was set to false.
Version 1.1.0 — March 20, 2011
- Added an option to invert the slides (right slide on bottom, left slide on top).
- Added a class to the previously opened slide.
Version 1.0.1 — January 10, 2011
- Fixed an issue with child elements breaking timer.
Version 1.0.0 — December, 2010
- First release.
Hello,
is there a way that no slide is by default wide? Now by default is 0, so the first but i wanted no slide open. Only bymouse over.
Thanks and regards, Michael
Hi Michael,
At the moment, there is no way to set the slides at an even width, and then expand them on mouseover. zAccordion slides are layered rather than set up side by side. It might be something I look at implementing in a future release.
- Nate
Very nice slider! Trying to get it to work with multiple instances. Has anyone been able to get it to work?One instance works fine in wordpress, but won’t go beyond that.
Hi Ken,
It will work with multiple instances. The examples.html file in the zip has about a dozen instances on a single page.
- Nate
Hi and thanks for a great script, it’s really awesome!I’d like to know how to trigger a slide opening by clicking on an external link instead of the slide itself.
thanks a lot!
Hi Mariano,
The Advanced Example shows how to trigger a slide by clicking a link.
Hi Nate, awesome code.
I need to know if this is possible. I want the slides to rotate in a loop on load. The rotatingneeds to stop when any of the slide is clicked. I mean auto rotate until any of the slide is clicked. How do i do that?
Thanks
Hi Prital,
That is a good question – something that is not quite built in. zAccordion will by default fire a click on the jQuery selector’s immediate child element. So you won’t be able to stop the accordion by listening for a click on those elements.
If you want it to stop when a user click’s that element, for now you would have to stop the accordion by firing the stop command if a child within that immediate element is clicked. For example:
$("#example li img").click(function() {$("#example").zAccordion("stop");
});
Where
$("#example").zAccordion()built the accordion and your elements are list items.Great job and greatly appreciate this tool.
Everything is going great and im using it for a mobile site and its flawless functionality.
My one question is how to turn the focus off on click. For example, when clicking on a slide on lets say the iphone/ipad you see the focus bleed down past the slider.
How would i get that not to display so that on click it moves without the button effect of the focus. removed url
Hi Rory,
It looks like that is specific to webkit. Setting the -webkit-tap-highlight-color property seems to work. For example:
.slide {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
Hi Nate,
Great bit of jquery. I was wondering if you had any tips on making it responsive? It looks like the javascript requires you to enter a hard width and height…could it be configured as a percentage of the screen resolution?
Hi Jesse,
You can use percentages. There are examples in the download that use percentages. Here is a quick snippet of what some settings would look like:
tabWidth: "20%",
width: "100%"
The accordion would be set to 100% of its container. The container size could even vary if you set its width using CSS3 media queries.
That method would make the accordion responsive in the fact that a user could essentially drag the corner of their browser and the panels would shrink with the page.
Another route you could try would be to build the accordion based on the screen size. For example, you could use something like window.innerWidth (checking the screen size on load), and set the width and slideWidth settings based on the number of pixels available. For mobile screens, or screens around 320 pixels wide, you could decide not to build the accordion and stack the slides on top of each other. If you wanted to go a step further and have that type of accordion respond when the window is resized, you could try using $(window).resize(). A function would need to check the width of the page and destroy (then rebuild) the accordion based on the new view. For example:
$(window).resize(function() {
if ((window.innerWidth >= 800) && (window.innerWidth < = 1200)) {
$("#featured").zAccordion("destroy");
$("#featured").zAccordion({
slideWidth: 600,
width: 800,
height: 310
});
} else {
/* ... */
}
});
I haven't tested the code, but something like that should work.
Truly awesome! Great piece of work Nate!
Having the
animationStart: function() {
console.log($(“#accordion”).data(“current”));
}
really gives the flexibility to control actions for individual slides! Can’t fault this accordion at all! 5 stars!
Great plugin! I tried other horizontal accordion plugins, but this one surpasses them all. It’s highly customizable, easy to use, accomplishes everything I need, and the animationStart, animationComplete and afterBuild actually work! Thank you for developing such a great piece of work and for releasing it to the community.
Is there an issue with transparency in IE? The example here http://www.armagost.com/zaccordion/another-advanced-example/ looks perfect in Chrome, Firefox and Opera, but the transparent section is solid black in IE 8.
Hi Ian,
I use CSS3 to create the shadows. I don’t believe box-shadow is supported in IE8. You can remove the shadow rule or even try an image for IE.
Hello!
It’s wonderfull, but is there a way to make it a vertical slide?
thank you very much
Hi Mac,
At the moment I don’t have plans to create a vertical version.
Great accordion code! Much appreciated. I do have one question. I am creating a “open” function and need to know which picture was opened. I was expecting a .value or .index value to represent which picture was opened. Can you point me in the direction where i can find this?
Thanks!
Steve
Hi Steve,
With the new release you can use animationStart. For example:
animationStart: function() {
console.log($("#accordion").data("current"));
}
The JavaScript above will log the current slide to the console.
is it possible to make zaccordian initially display all images partially collapsed and of all equal widths and return to this state when mouse is out off the accordian ?
thanks
Hi Chris,
If I understand the question, you want zAccordion to stretch when hovered over. Unfortunately, the plugin does not work that way because I wanted a different effect. zAccordion essentially layers one piece of content over another instead of displaying the content side by side. There is a good possibility that other plugins out there will work for you. One that comes to mind is the original MooTools accordion.
Thanks dude !
Your plugin is just awesome !
Best Regards
hi, this is an amazing accordion! i’ve been playing around with another one and it was an absolute nightmare! stumbled across yours and i am beyond impressed!
i currently have my accordion set on mouseover, i’m wondering if there is a way of getting the accordion to reset back to the starting slide if i mouse off?
thank you!
Hi Aron,
Thank you for the comments. The accordion won’t call a function on mouseout or mouseover. It is a good idea. I will take a look at that for the next release.
This is really nice – very straightforward and neat. Thanks!
Do you have any “no-js” type class that we can apply before the js kicks in, so we can hide the initial lining up of the li items?
Thanks,
Hi Tim,
In the latest release (1.1.2) I’ve added a function that fires after the accordion is built (afterBuild). See the examples.html file in the download for an example – the last accordion will fade in once everything is ready.
You could do something similar by removing a no-js class using afterBuild.
-Nate
Yay! Got it working and love it!! Works great with jquery 1.5!!!
Took a lot of trobleshooting…. The lastest jquery (1.6) causes some weird looping issues in Chrome (tried a different accordion with the same issue, but it seems like a Chrome exclusive problem) … not sure what causes the issue. When you are away from the page the autoplay seems to pause and then try to catch up when you return to the page (speedily plays the slides and won’t stop them on mouseover until it plays all the playback you missed).
Hi Megan,
I do see that issue with Chrome. I think I’ve fixed the issue in the next release. It looks like it is related to the events building up similar to the “click happy” user mentioned in another comment above.
WOW! This is the most amazing and best looking horizontal accordion script I came across. Thank you!!
Nice plugin,
I tried to emulate “click happy” user, and seems the event keep adding up. if the handler is mouse over / hover then it can hog the computer down if user is moving the mouse cursor like crazy.
IMHO it is a good idea to force user to wait for the current animation finished before they can create another animation event.
Again that is only my 2 cents.
Cheers
Hi Vic,
Good idea. I’ve added a stop() before the animation and it seems to clear up the issue. The solution is similar to the one seen here. It will roll out in the next release.
Having problems with disabling autoslideshow thingy, have set auto:false so it does not start.
but if i click the nav links it starts to slide
anyway arround this?
great work btw!
Hi skepsis,
I do see that issue. It is fixed in the upcoming release.
Thank you. This is amazing and exactly what I was looking for.
Hi! Great work, thanks! I simply love the shadow effect rendered under accordion tabs.
But I wanted to ask – is there an option where tabs in the left side of accordion is on top of those which are in the closer to right side. To be more precise – the mirrored version of this accordion above. I am using this plugin in my blog/album page, so I would like to make it look like stack of pages on the left side of desk (hovering will reveal each of them in acoordion way).
Hi,
I’ve had a couple requests for this. I am hoping to implement this feature in the next release. However, that may not be for another week or so.
- Nate
* Update this feature was released with version 1.1.0.
Hello, veeery nice script !!
I have question, how to invert “layers” (left image on top, right image on bottom)?? Thanks !!
Hi Ajdacho,
I’ve added this into the new release.
Hi,
Love the accordion! It’s nearly perfect for my needs, but I’d also like to display a text area on the closed tabs – something like the accordion at http://www.bbc.co.uk/food/
Do you have plans to add something like this? I’m new to jQuery and tried adding an extra div that would fade out when the slide became active ( inverse of the $(“#splash”).find(“li.slide-open div”).fadeIn(); call), but it ended up fading in, out and back in again.
Anyway, it looks great. Cheers for making it available.
Hi Adam,
I’ve created an example of a BBC style accordion with the latest version of zAccordion.
Thanks – best looking horizontal accordion on the net and the easiest to get working!
Buenísimo! muy simple.
Hi, awesome script. I think I’m definitely going to use this in my next project. I’m not a javascript/jquery wiz though I’m wondering what it would take to make it into a vertical accordion?
Hi Michael,
Sorry, at this time I don’t have plans to make it into a vertical accordion.
Oh, that’s wonderful.
I wonder how could I omit the slide show, using the click event only? Sorry for such a dummy’s note.
Hi Pavel,
Try setting the auto option to false. That should work.
Beautiful script. But is there any mouseOver features? Or any way to add it?
Hi Andrei,
You should be able to change the trigger option to switch slides on mouseover instead of click. The accordions packaged along with the download should have an example of this.