Just wrote something up for a .slideToggle for a "Read more.../Read less...", the issue is that at the end of the slide, the animation "jumps", for a lack of a better description. Likewise when the slide is started again. Any suggestions?
I have it in jsFiddle
EDIT: I'm using Chrome
<div class="details">
<p>I am an excerpt.</p>
<span class="show">Read More...</span>
<div class="info">
<p>the info to show in here......</p>
</div>
</div> <!-- details -->
<div class="details">
<p>I am an excerpt.</p>
<span class="show">Read More...</span>
<div class="info">
<p>Some different info to show in here......</p>
</div>
</div> <!-- details -->
$(document).ready(function (){
$(".info").hide();
$(".show").click(function(event) {
$(this).parent(".details").children("div.info").slideToggle(300);
$(this).text($(this).text() == 'Read More...' ? 'Read Less...' : 'Read More...');
});
});
Thanks!
You can eliminate the jumpiness by removing the margin on the last child element the sliding container. I believe it has something to do with jquery calculating the height including the margin, then when display block is applied the margins collapse on the others.
.info p{
margin-bottom:0;
}
http://jsfiddle.net/QzStg/4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With