我有以下代码: http://jsbin.com/havesixufo/edit?html,output
只有向下滚动才有效,但向上滚动时,div 会得到 2 个类,而不是 1 个。您可能会说,只需反转向下滚动时所做的操作,但不起作用。
最佳答案
将 UP 部分中的 if block 代码更改为下面的
if(bottom >= prevElement.center.bottom && bottom <= element.top.top){
prevElement.target.addClass('center').removeClass('bottom');
}
if(stCenter <= element.top.center && bottom >= prevElement.center.bottom){
element.target.addClass('top').removeClass('center');
}
关于javascript - 动画只有一种方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39489125/