Good day.
The following question arose:
On the page there is a form to fill out, which, if it is empty, must be folded (as if by an accordion, we can only see the arrow pointing to the turn down). When hiding and opening I use the slideDown
and slideUp
. But for some reason, the animation is sometimes quite jerky and stepped. Here is a sample code:
$("#arrow").click(function() { if ($("[data-status]").attr('data-status') == "true") { $("[data-status]").attr('data-status', false); $(".my-form").slideUp(400, function() { $("[data-status]").removeClass("icon-chevron-down").addClass("icon-chevron-down"); }); } else { $("[data-status]").attr('data-status', true); $(".my-form").slideDown(400, function() { $("[data-status]").removeClass("icon-chevron-down").addClass("icon-chevron-up"); }); } });
.my-form { width: 100%; margin-left: 0; padding-top: 15px; border: 1px solid #CCCCCC; border-top: none; overflow: hidden; }
<div> <div class="span12"> <i class="icon-chevron-up" data-status="true" id="arrow"></i> </div> <form action="adress" id="form" method="get"> <div class="span12 my-form" style="display: block;"> ...... </div> </form> </div>
The height of the form is not specified, because she is adaptive.
The bootstrap
used (as far as I can tell from the available functions about 2) and jquery 2.0.3
.
Tell me which way you can dig, thanks in advance.
PS Link to JSfiddle: http://jsfiddle.net/7xpdwdnv/