is there an easy way to detect the event when an accordion has expanded?
Wednesday, April 09, 2014 at 11:28 AM EST
Check out this Pen I made: http://codepen.io/winghouchan/pen/Lqfhw
This should get you on the right track. You will need to open up your Console as the script logs when Accordion is opened and closed.
but it is not quite what I am looking for. Detecting the click like in your Pen only tells us when the dd elements in the accordion is about to open/close. What I am looking for is the detection of the event when the content actually becomes visible.
Sorry, I don't quite get what you want.
The click immediately precedes the Accordion tab open/close. So detecting the click is probably the best way to detect if Accordion has opened or closed.
My use-case for accordion is that each of the DD has content with scrollable divs of sections. What I want to make sure is that when a DD is clicked and the content expands, the selected item in the div is scrolled into view. I can compute with scrollTop() to do that. However, the computation only works if the containing div is not hidden. That is the reason why I need a way to detect when the content of the DD becomes visible.
Detection of the click events as described in your Pen precedes the event when the content becomes visible. I cannot do the computation then as the content would still be hidden.
Thanks for you input!
Thank you for the giving the situation!
Yep, that's true.
I guess you could add a very short delay — that the user won't notice, maybe about 50ms — after the click event and before the computation starts.
Not sure if this would work but you could try it.
Create an Account
Get up to speed FAST, learn straight from the experts who built Foundation.
Learn Foundation from the creators in our interactive online webinars which will keep you up to date with the latest trends and skills needed to win your projects.
Or if you prefer, contact the Foundation Team at [email protected] or (408) 341-0600 x635