如何在滚动手风琴分区上进行操作

How to make action on scrolling accordion div

本文关键字:操作 分区 手风琴 滚动      更新时间:2023-09-26

我有一个手风琴菜单。我想对滚动到手风琴项目内容的末尾进行操作。我想做

$("#Akordeon1Content").scroll(function() {        
    if($("#Akordeon1Content").scrollTop() === $("#AkordeonContainer").height() - $("#Akordeon1Content").height()) {
        alert("dsadas");
    }
}

但它不起作用。有人知道怎么做吗?

设置一个新参数:

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);}
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);
 }