2015-10-05 373 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);