我收到了手风琴菜单。我想在滚动到手风琴项目内容结束时采取行动。 我试图做
$("#Akordeon1Content").scroll(function() {
if($("#Akordeon1Content").scrollTop() === $("#AkordeonContainer").height() - $("#Akordeon1Content").height()) {
alert("dsadas");
}
}
但它不起作用。有人有任何想法如何做到这一点?
答案 0 :(得分:0)
function otworz(index)
{
var nID = "Akordeon" + index + "Content";
var nazwa = nID;
if(Akordeon_otw === nID)
nID = '';
animate(new Date().getTime(),TimeToSlide,Akordeon_otw,nID);
Akordeon_otw = nID;
}
function animate(lastTick, timeLeft, closingId, openingId)
{
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;
var opening = (openingId === '') ? null : document.getElementById(openingId);
var closing = (closingId === '') ? null : document.getElementById(closingId);
if(timeLeft <= elapsedTicks)
{
if(opening !== null)
opening.style.height = ContentHeight + 'px';
if(closing !== null)
{
closing.style.display = 'none';
closing.style.height = '0px';
}
return;
}
timeLeft -= elapsedTicks;
var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);
if(opening !== null)
{
if(opening.style.display !== 'block')
opening.style.display = 'block';
opening.style.height = (ContentHeight - newClosedHeight) + 'px';
}
if(closing !== null)
closing.style.height = newClosedHeight + 'px';
setTimeout("animate(" + curTick + "," + timeLeft + ",'"
+ closingId + "','" + openingId + "')", 33);
}
答案 1 :(得分:0)
设置一个新的参数:
animate(lastTick, timeLeft, closingId, openingId, callback)
清除动画中的超时时添加此功能:
callback();
不要忘记将您的函数传递给animate函数:
animate(new Date().getTime(),TimeToSlide,Akordeon_otw,nID, function( ){[...]});
并且不要忘记将回调传递给下一个动画:
setTimeout("animate(" + curTick + "," + timeLeft + ",'" + closingId + "','" + openingId + "', " + callback + ")", 33);}