2015-10-05 371 views
0

我需要在运行animate事件时检测div的“collectionFilterPage”的总高度。有什么事情要约束吗? 这是我的JA代码:jquery触发器div高度变化事件(动画?)

function showMoreItems() { 
    $("#collectionFilterPage").animate({ 
     height: "+=720" 
    }, 1000, function() { 
     if ($("#collectionFilterPage").outerHeight() >= $(".lista").outerHeight()) 
      unbindScrollEvent(); 
    }); 
} 

基本上,我会想火“unbindScrollEvent”当两个格“collectionFilterPage”和“LISTA”具有相同的高度。 谢谢

回答

0

解决。这已经很不容易了

高度:$( “#collectionFilterPage”)outerHeight()> = $( “LISTA。”)outerHeight()。? “+ = 0”:“+ = 720”

1

你可能想切换到这个$().aninate签名,并使用step属性,它允许你设置它们是在动画的每一步称为一个回调函数。

function showMoreItems() { 
    function checkHeight() { 
     if ($("#collectionFilterPage").outerHeight() >= $(".lista").outerHeight()) 
      unbindScrollEvent(); 
    } 

    $("#collectionFilterPage").animate({ 
     height: "+=720" 
    }, { 
     duration: 1000, 
     complete: checkHeight, 
     step: checkHeight 
    }); 
} 

$(...).animate(properties, options);