I have a function that hides or shows a filter:
function slide(event) {
//a search engine filter
var $sideFilter = $(event.currentTarget).prev();
//an arrow that switches its orientation based on collapsed or not
var $arrow = $(event.currentTarget).find(".arrow");
//if not hidden, find current height of element (is variable height)
if (!$sideFilter.hasClass("fc-hidden")) {
var currentHeight = $sideFilter.height();
//set it so that animation has concrete height to go from/to
$sideFilter.css("height", currentHeight.toString());
}
$sideFilter.toggleClass("fc-hidden");
$arrow.toggleClass(".arrow-rotated");
//set height back so that it can be variable
$sideFilter.css("height", "auto");
}
for some reason, the css animation on the height only plays when i step through it using the debugger. It seems as if by the time the class is toggled (animation is on the side filter class, and height is changed through application of fc-hidden class), the function is not yet aware of the height of the filter, and thus, does not know how to animate. If i do it step by step, it works perfectly.
Ideas?