gpt4 book ai didi

javascript - Jquery触发div高度变化事件(动画?)

转载 作者:太空宇宙 更新时间:2023-11-04 11:19:02 25 4
gpt4 key购买 nike

我需要在动画事件运行时检测我的 div“collectionFilterPage”的总高度。有什么事件可以绑定(bind)吗?这是我的 ja 代码:

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

基本上,当 div“collectionFilterPage”和“lista”的高度相同时,我想触发“unbindScrollEvent”。谢谢

最佳答案

您可能想切换到此 $().aninate 签名并使用 step 属性,它允许您设置在每个步骤中调用的回调函数动画。

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

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

http://api.jquery.com/animate/

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

关于javascript - Jquery触发div高度变化事件(动画?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32949280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com