我有一个很大的可滚动区域。在一个部分中,我有一个缩略图的网格。单击时,将克隆拇指并将其动画显示到屏幕的中心。然后,克隆的图像淡出,框变大,然后将相关文章加载到使用(eq)index点击的拇指上。
文章加载得很好,所以我知道我的目标是正确的,但因为每篇文章根据其内容有不同的高度,我需要在出现之前调整相应文章的高度。我好像不能让它起作用。我试图将高度传递给一个变量,并将高度动画化为此值,但当长方体将其高度动画化为0时,它似乎返回0。如果我设置一个像素值,这是可以的,但这会在底部留下很多空白。\我使用的代码是:
var index = newsover.index($(this)); //cycle through read more links
var offset = $(this).offset(); //Get the thumb position to animate from
var animFinished = false; //Create boolean to check when ani finishes
$('#news-articles .news-article').hide().eq(index).show(); // show the article for the corresponding link and hide the others
var article = $('#news-articles .news-article').eq(index);
var articleClone = article.clone(true); // clone the article for the corresponding link
var articleHeight = article.height();然后,它被编码为动画到中心,并淡出拇指图像,这一切都很好。然后:
//expand the box further from the center
expandFurther = function() {
expandedItem.animate({
width: 875,
height: articleHeight,
marginTop: -articleHeight/2,
marginLeft: -875/2,
}, {
duration: DDBR.constant.ITEM_ANIMATION_SPEED,
easing: DDBR.constant.ITEM_ANIMATION_EASING,
queue: false,
complete: function() {
animFinished = true;
if (animFinished) {
loadContent();
}
}
})
}; //END expandFurther function任何帮助都将不胜感激。在此之前,非常感谢您。
发布于 2012-05-17 16:21:27
我使用一个名为actual的jquery插件让它工作。我把它整理好了。这里有个链接:http://dreamerslab.com/blog/en/get-hidden-elements-width-and-height-with-jquery/
非常感谢所有帮助我们解决这个问题的人。
发布于 2012-05-17 01:31:33
我不能从您的描述中完全判断,但听起来您得到的高度是零,因为在动画完成之前,您实际上不会加载文章内容,所以您看到的容器的高度当然是零--它是空的。
为了动画到正确的高度,您需要以某种方式加载文章内容--或者在实际容器中,或者在(可能不可见的)虚拟容器中。
https://stackoverflow.com/questions/10623524
复制相似问题