I'm using the slide animation from jQuery UI to insert a div between two others in a row, but when triggering the animation, what happens is the space needed for the div to slide jump appears without animation and then animation comes in.
EDIT: JSFiddle issue fixed thanks to the guys below. New JSFiddle is: https://jsfiddle.net/7ryukzd7/3/ But the initial issue remains :-)
For a reason I don't get, in JSFiddle the div doesn't slide inline but breaks (which doesn't happen in a browser)... Anyway the point is illustrated nonetheless. (this is now solved)
My code:
HTML:
<div class="bloc cover" style="background-color: blue;"><p class="readmore_button">Read More</p></div>
<div class="bloc hidden" style="background-color: red"><p>Lorem ipsum dolor sit amet. </p></div>
<div class="bloc cover" style="background-color: blue;"></div>
<div class="bloc cover" style="background-color: blue;"></div>
CSS:
.bloc {
display: inline-block;
vertical-align: top;
}
.cover {
width: 100 px;
height: 100 px;
}
.hidden {
height: 100 px;
width: 200 px;
}
JS with jQuery UI:
$('.hidden').hide();
$('.readmore_button').on('click', function() {
$(this).parents('.bloc').next('.hidden').toggle("slide", 1000);
});
I saw similar issues here: jQuery UI show using slide animation jumps to full height before animation starts but couldn't adapt it to my situation.
Any help would be much appreciated, either on the reason why inline-block breaks with animation in JSFiddle (solved) or on the actual issue :-)