Main problem: #slidesContainer needs to be dynamically changed so that the parent can know how much time it takes to scroll. One way to solve the problem is to change your animated call to include a callback:
$('#slideInner').animate({ 'marginLeft' : slideWidth*(-currentPosition) },null,null, function(){ $('#slidesContainer').css('height', $(this).children(".slide:nth-child(" + parseInt((Math.ceil(-1*slideWidth*(-currentPosition) / $("#slideshow").width())) + 1) + ")").height() + "px"); } );
There is probably a slightly better way to do this calculation, but it will work. You can also hide all other .slide divs that are not displayed. Then #slidesContainer will automatically resize only to the visible (not visible: none) slide.
Joeyp source share