I have a strange behavior with css transitions. I want to hide/show an image with a transition effect. I set up html:
<div class="up">
<div class="wrapper_hiden wrapper_see">
<img src="">
</div>
...
</div>
<div class="down">
</div>
and css:
.wrapper_hiden{
height: 0;
float: left;
margin: 0;
opacity: 0;
transition: all 1s;
overflow: hidden;
}
.wrapper_see{
height: 100px;
margin: 5px;
opacity: 1;
}
.wrapper_hiden img{
height: 100%;
}
Now if I use JQuery to toggle wrapper_see class I can show/hide image with effect. Here is fiddle with a button to do that.
Problem start when I want to hide element and after hidden prepend it to another div and show. Basically I want to move image from div to div but with transition effects.
$('body').on('click', '.up .wrapper_hiden',function(){
var $wrapper_hide = $(this);
$wrapper_hide.removeClass('wrapper_see');
$wrapper_hide.one('transitionend', function(e) {
$(this).prependTo('.down').addClass('wrapper_see');
});
});
However transition efect is not reacting after prepentTo.
Have spent hours but can not understand why it works with first approach but dont with second.