【发布时间】:2017-03-14 08:43:31
【问题描述】:
我有list that scrolls up using velocity。我想每次播放声音,列表的第一个可见项目向上滚动。
<div class="viewport" data-winner="">
<ul class="participants-holder container" id="ph">
<li>...<li> //many li elements
</ul>
</div>
moveToEl(name) {
...
$(container).velocity({
translateY: -(offsetToScroll)+'px'
}, {
duration: 15000,
easing: [.74,0,.26,1],
complete: (el) => {
...
// complete animation callback
},
progress: (els, complete, remaining, start, tweenVal) => {
console.log(Math.floor(complete * 100) + '%')
// I think some check should do during progress animation
}
})
}
当每个元素或整个列表向上滚动特定像素时如何处理事件或跟踪更改,例如62px。我怎样才能检测到这种情况并在发生这种情况时调用回调函数。
【问题讨论】:
-
请在问题本身的minimal reproducible example 中提供所有相关代码,而不仅仅是在第三方网站上。
-
@MikeMcCaughan 先生,我添加了部分代码。
标签: javascript jquery velocity.js