在野生动物园中处理与滚动事件相关的动画的正确方法是什么(例如两个元素之间的滚动同步)?
我今天使用的解决方案可以在Chrome和Firefox上无缝运行,但是在Safari中确实很笨拙。
总结代码,就像:
element.addEventListener("scroll", () => {
window.requestAnimationFrame(){
otherElementWithScroll.scrollTop = element.scrollTop
otherElementWithHorizontalScroll.scrollLeft = element.scrollLeft
}
})
otherElementWithScroll.addEventListener("scroll", () => {
window.requestAnimationFrame(){
element.scrollTop = otherElementWithScroll.scrollTop
}
})
otherElementWithHorizontalScroll.addEventListener("scroll", () => {
window.requestAnimationFrame(){
element.scrollLeft = otherElementWithHorizontalScroll.scrollLeft
}
})