我有一个巨大的可滚动区域。在一个部分中,我有一个缩略图网格。单击时,拇指将被克隆并动画到屏幕中心。克隆的图像然后淡出,框变大,然后将相关文章加载到使用 (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
任何帮助将不胜感激。提前谢谢了。