scroll - 在 Safari 上处理滚动动画的正确方法是什么
问题描述
在 Safari 中处理与滚动事件相关的动画的正确方法是什么(例如两个元素之间的滚动同步)?
我今天使用的解决方案可以在 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
}
})
解决方案
推荐阅读
- javascript - 无法使用等待 mongodb 查询中的变量
- algorithm - 这个算法的(大 O)复杂度是多少?
- matplotlib - yticks() 中的 Matplotlib 开发应用程序问题
- django - Django 和 AWS S3:对错误 URL 的静态文件请求
- bash - 需要 Powershell base64 编码
- linux - 我的 Bacula 传输率非常低。我如何配置导演来改善这一点?
- linux - gzip 使用什么临时内存?
- javascript - 淘汰赛:在列表中的对象上实现“聚焦”
- reactjs - react-native flatlist 不会在元素更新时重新渲染?
- oracle - 根据另一字段条件过滤一个字段高于值的数据