//

Auto collapse FAQ accordion

Previously I have created a FAQ accordion cloneable but the opened items will not auto collapse when other items are opened. Using pretty much the similar interaction from the previous cloneable, I added some custom scripts to conditionally add a combo class and trigger clicks.
Instead of targeting the class, it's targeting data-attribute. User can change the class naming without having to worry about updating the script.

Scroll down to view cloneable . . .
*Copy all elements inside the container named 'Cloneable Area'
First step, create the FAQ accordion structure.

Basically, you can design anything that you can ever imagine. The main thing here is to have a parent container and two child elements. One for the FAQ question and another for FAQ answer. The child element for FAQ answer should be set to overflow: hidden and transform-origin set to top mid.

Next, setup the interactions.

Depending on how fancy you want it to be but the concept here is to apply the interaction to the parent element. Use 'Mouse Click' interaction to resize the height of FAQ answer element. Initial state should be set to height: 0px. On first click, resize to height: auto and on second click, resize to height: 0px.

To make the other items auto collapse, add in custom script.

The first two steps pretty much got the main function works. As for the auto collapse, copy the code from the page custom code section before tag and paste into your project. Voila, that's all and you're good to go.