Bootstrap collapse animation not smooth
In case anybody else comes across this problem, as I just have, the answer is to wrap the content which you want to collapse inside a div
and collapse the wrapper div rather than the content itself.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group">
<a for="collapseOne" data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne" class="btn btn-primary">+ addInfo</a>
<div id="collapseOne" class="collapse">
<textarea class="form-control" rows="4"></textarea>
</div>
</div>
<div class="form-group">
<a for="collapseTwo" data-toggle="collapse" href="#collapseTwo" aria-expanded="true" aria-controls="collapseOne" class="btn btn-info">+ subtitle</a>
<input type="text" class="form-control collapse" id="collapseTwo">
</div>
Jerking happens when the parent div ".collapse" has padding.
Padding goes on the child div, not the parent. jQuery is animating the height, not the padding.
Example:
<div class="form-group">
<a for="collapseOne" data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">+ addInfo</a>
<div class="collapse" id="collapseOne" style="padding: 0;">
<textarea class="form-control" rows="4" style="padding: 20px;"></textarea>
</div>
</div>
<div class="form-group">
<a for="collapseTwo" data-toggle="collapse" href="#collapseTwo" aria-expanded="true" aria-controls="collapseOne">+ subtitle</a>
<input type="text" class="form-control collapse" id="collapseTwo">
</div>
Fiddle Showing Both
Hope this helps.
Adding to @CR Rollyson answer,
In case if you have a collapsible div which has a min-height attribute, it will also cause the jerking. Try removing that attribute from directly collapsible div. Use it in the child div of the collapsible div.
<div class="form-group">
<a for="collapseOne" data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">+ Not Jerky</a>
<div class="collapse" id="collapseOne" style="padding: 0;">
<textarea class="form-control" rows="4" style="padding: 20px;">No padding on animated element. Padding on child.</textarea>
</div>
</div>
Fiddle